Refactoring and improving unit test.