Fully Homomorphic Encryption over the Integers with Shorter Public Keys
If I understood well, you have two issues:


About the $2\beta$ values of $x$ "generating" $\beta^2$ values
About your the bugs in your code.


So, answering (1):   Notice that in the summation (and in your first for loop) for each $x_{i,0}$ you have $\beta$ different values of $x_{1,j}$, which means $\beta^2$ combinations of those $2\beta$ values. You are using the $2\beta$ values you have to perform $\beta^2$ products. Nothing special here.

The point (2) is harder because there are a lot of possible causes to the malfunction of your program. My first guess would be that you are not multiplying $r$ by $2$ in the line

c=c.add(m1).add(r).add(summation);//c=m+2r+2∑x


but it may also be some problem with the intervals each parameter has to belong (are you sure you are respecting them?) or some other restriction imposed on the values. For instance, $x_0$ must be a product of a prime number $p$ with a random odd square free number $q_0$ that does not contain prime factors smaller than $2^\lambda$...

All those restrictions are there to guarantee security or correctness.