bug fix and test case