refactoring and unit test example