added more tests, very minor refactoring