Fix flawed DoH unit tests logic and some corner cases in the DoH code. Fix doh_test failure on FreeBSD 13.0
This merge request fixes some logical mistakes in DoH unit tests logic, causing them either to fail or not to do what they are intended to do under some circumstances. Also, it fixes some corner cases found in DoH as a result of tests now working reliably.
As a side effect of the fixes,
doh_test now works reliably on FreeBSD 13.0, thus the MR closes #2632 (closed), allowing the platform to be added to the CI pipeline.