added some more tests and refactored