SCHEMA-369. Fix the JUnit tests so that exceptions are properly caught and validated.

Fix the JUnit tests so that exceptions are properly caught and the messages in
them validated. This ensures that the right line that is expected to throw the
exception is tested or the test fails.

Reviewer: taton