added more tests and refactored a bit