Fix bug and reproduce it in the tests.