Refactoring and Tests