SERVER-5064 Improve error reporting in test

Adjust code to catch exception during query attempt so that assert
runs and prints stack trace, display message on assertion failure.