Fixes #302 simplifies json decoding and handling of errors. Adds tests.

This fixes the odd logic in the json decoding. I pushed the decoding burden onto the requests library.

I also cleaned up the logic for processing errors.

Unit tests added for the changes.