fix problems picked up by unit test