fix bug and test