Fixing some mistakes in the tests and in the respective implementation.