Unit tests for refactored exception handling code