unit tests with refactored code