Tweaking how errors are thrown + adding test for non-json API responses