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.
Can this be moved to a separate PR that's not docs/tests ?