Stop using predictable paths under /tmp for tests

Most of the tests use predicable paths for intermediate files in /tmp.
This is a problem on multi-user systems, as it makes the test suite
vulnerable to symlink attacks. It may also cause problems with things
like buildds.

All tests except 'test-extract' are fixed in this patch (that's a
bigger piece of work).