refactored the proxy implementation, and some old tests
commit before keep-alive-agent test on socket level