Adding exception handling for the tests