code cleanup: better test coverage for exception handling.