unit testing & refactoring