fix a bug and a test