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.
JSON doesn't support numbers for object keys, and the stock decoder will raise a ValueError.
However, I'll keep this anyway.