cleaned code and add more test coverage for proxy