Code and Test Refactor