Refactor unit test properly