refactoring and unit test prep