refactoring, unit tests