RPC refactoring: Code cleanup and tests.

This also drops the dependency to mocker.el and rework all tests
to use our own mock macro.