Fix coverity failures in unit tests as of 19 August 2019

Other than legacy/trac#31451 (moved) and a deadcode issue in trunnel, our current "new" and "triaged" issues are all in the unit tests.

Let's fix them all, to keep our code quality up.