discovered a bug and added more tests