TS-1475: Fix memory leak in regression tests. Coverity #1022150