add test and bug fix