Fix issue with using expected exception in tests
Merge pull request #6054 from stuartwdouglas/fix-tests

Fix issue with using expected exception in tests