Refactor unit tests