modify dns.py to catch in outer method and corresponding unit-test