add more testcase and fix bugs