Added some tests.  Cleaned up some exception handling.