Fix bugs for test cases.