Fixed bugs in / around the unittests that were not caught because of the unittests failing to run