add the test case and fix bug