more fixes, tests pass (97% coverage, down to hard-to-test conditions)