Fixed a unittest and added some more cleanup in unittests