Prefer assert_raise instead of flunk + rescue to test for exceptions

Change most tests to make use of assert_raise returning the raised
exception rather than relying on a combination of flunk + rescue to
check for exception types/messages.