Refactor some unit test.