Make exception tests work in debug mode

fixes #2452