Using assertions to handle exceptions in tests