Fixed several bugs in the new unit test code