utility function to test for expected exceptions in unit tests (#127)