Refactor unit tests with utility class