Add tests for proxy_contexts and fix bugs.