unit tests, refactoring