fix dns_d_trim and add command-line wrapper to test it