refactoring and unit tests
refactoring and unit tests