Fix unittests and patch some coverage holes.