Extract proxy/config common functions for reuse

Refactor proxy to use the common config.  This is a prereq for #356 and the commits 
have had feedback from @thockin only.
Also fix tests.
I think this is safe, but only because you can't remove a listener. Consider doing the loop while locked, and doing ```go OnUpdate()```?