Fixing actual bug found by unit tests