Update test to supress stderr

Noticed this when running unit tests.  The error message
was being printed to stderr.  Now the test catches and
verifies the error message.

I also updated the existing tests to:

* Use mock.patch.  Otherwise test failures will leave sys.stdout
  monkey patched and could affect subsequent tests.
* Also replaced the output.find() calls with assertIn().  This will
  give a detailed error message that includes the original output.
  Also the tests were checking against '!= 1', but find() return -1
  if the substr is not found in the str.