added test and bug fix