Made Rest proxy stuff more modular and testable. Added test.

I added a test for RestInvocationHandler. I'm not pushing directly into develop now because of the planned release.