Fix test cases and errors found while fixing test cases.