Added some more tests + refactoring