Fix error revealed by unit tests