Update test case and fix bugs.