improved RPC module to handle promises as a reply.

Improved unit tests, reproduced non-error reporting in nodejs, dont know how to fix