more tests, refactoring