unit test and manage exceptions