add some tests and fix various ways of exiting with exceptions