Small refactoring, more tests