Fixing a bunch of bugs, adding a bunch of tests. This was a bug introduced in variable space expansion. Fix will come in future commit.
Fixing bad unifications in variable space.