Updated test logic to report exceptions gracefully.