DNS unit test and logic fixes