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.
Ah, yeah, I think it is safe if you implement remove like that. I guess it's a moot point since there's not really a way to remove a specific listener at all, as the listener interface doesn't have any way to check equality...