js/rest-adapter: fix bunch of issues

Fix issues found while implementing spike of LoopBack Javascript SDK.