Finding a space with given homology groups and fundamental group I started thinking a couple days ago about the example below, and it led me to ask the following question: 
How (or when?) can we build a space (let's say a CW complex) with given homology groups and fundamental group? I know we can do either of these separately, but I couldn't do both simultaneously even for the simple example below. Also, can we have two such spaces $X, Y$ such that $X$ is not homotopy equivalent to $Y$?
EDIT: It's a necessary condition that the group we want as an $H_1$ is the abelianization of the one we want as $\pi_1$.
This is the example:
We want to know if it's possible to find a space $X$ (not homotopy equivalent to $\mathbb{T}^2$) such that $H_n(X) \cong H_n(\mathbb{T}^2)$ and $\pi_1(X) \cong \pi_1(\mathbb{T}^2) \cong \mathbb{Z}^2$.
For example, the space $X= S^2 \vee S^1 \vee S^1$ has the same homology as the torus, but has fundamental group $\mathbb{Z}\ast\mathbb{Z}$. I thought of attaching a $2$-cell to $X$ to add the relation $aba^{-1}b^{-1}$, but this ends up giving me $Y = S^2 \vee \mathbb{T}^2$, which has $H_2(Y) \cong \mathbb{Z}^2$, so it's not what I want.
Any hints would be appreciated, thanks in advance. 
EDIT: It turns out a more general question was asked a few years ago. Qiaochu Yuan's answer goes a bit over my head right now, but it might be useful for someone else who comes across this. 
 A: This is a partial answer.
For any abelian group $G$ and integer $n \geq 1$, there is a CW complex $M(G, n)$ such that 
$$\tilde{H}_i(M(G, n)) = \begin{cases}
G & i = n\\
0 & i \neq n
\end{cases}$$
called a Moore space. Moreover, for $n > 1$, we can take these spaces to be simply connected. See Example $2.40$ of Hatcher's Algebraic Topology.
Using the fact that $H_n(\bigvee_{\alpha}X_{\alpha}) = \bigoplus_{\alpha}H_n(X_{\alpha})$, we see that for a given sequence of abelian groups $\{G_n\}_{n=1}^{\infty}$, the CW complex $X = \bigvee_{n=1}^{\infty}M(G_n, n)$ has the property that $H_i(X) = G_i$. 
However, all that can be said of $\pi_1(X)$ is that its abelianisation is $G_1$. There are many different groups with the same abelianisation, so $\pi_1(X)$ may not be the group you wanted it to be. 
If one could construct the Moore spaces $M(G, 1)$ with a given fundamental group (which must satisfy the necessary condition that its abelianisation is $G$), then the above space would have the desired properties. However, I don't know if this has been done.
Added Later: I asked a separate question about this final point (whether one could construct a Moore space $M(G, 1)$ with given fundamental group) here. It turns out it is not always possible.
A: Dont, know if this answers your question, probably not, but if $\pi_n(x)=0$ for all $n>1$ then the homology groups $H_n(X)$ are determined by $\pi_1(X)$ in fact they are the group cohomology of the group $\pi_1(X)$. So you may want to have variable $\pi_n(X)$.
A: Take the case where $H_1(X)=0$. It is not always possible since the first homology group is the abelianization of the fundamental group which is not always zero.
