fixed unit tests and misc cleanup