Added some more tests and little refactoring