bug fixed and test added