fixed a bug fix that was supposed to be fixed but that I unfixed
also added tests.