Refactoring and testing contact controller