More test coverage, esp for error handling cases.

Refactor out patching bad random, more err coverage.

Updated per Rog feedback.