Refactoring of the unit tests for exceptions