Update with full coverage in tests.
This version leaves the code mostly unchanged (beside commenting out some unused debugging code), and includes the unit test file that does full code coverage.
This version leaves the code mostly unchanged (beside commenting out some unused debugging code), and includes the unit test file that does full code coverage.