Task #781 DNS: fixed return values + code duplication