Fix a bunch of unit tests by using the unification logic from the original C++ code.