add test case, fix bug