Fixed solution. Added more tests and som refactoring