add test case and fix bug