backporting [rather just attempting to at this point] the test script to c++03
fixing some include guards
critical bugfix for the equivalence transform of terms