Correct various test memory leaks (PR #14745)

(see commit messages, to be rebased and merged)

GitHub

Yep LGTM, thanks :+1: