refactoring, add some more tests