Better errors

* Resubmitting pull request with private method to handle HTTP requests and errors consistently, and to pass through API error messages correctly.
* Includes new and refactored tests
* Also removes minor dead code for clarity