Added more tests and some general cleanup