adding more tests and refactoring some more