Bug fixed and test added