test_exec: fix potential races in fd leak test