Fix a few RPC corner cases and add tests

There were just a few corner-cases about the place which could cause an internal server error when they should instead work.
Not really. Three of the tests (test_body_not_json, test_body_not_map, test_body_not_string_keys) would fail without this.