Refactor some test cases