Fixed unification. Added unit tests.