Some unit test refactoring; fixed some random test breakage