Fix bugs in AlgebraicParticle & Variable
And added to unit tests