Corrected code to conform to Python coding conventions (PEP 8).

Added test code for handling exceptions.

Corrected test code to use the full path to the test data.