This makes the whole test happen in a clean temporary directory in
$TMPDIR/$random, and simplifies the test a bit by eliminating unnecessarily
dynamic path elements computations.
Before this patch, the first part of the test was happening in /tmp itself.
This allowed coincidentally named files placed in that directory to impact the
outcome of the test. Additionally, this made the second part of the test fail
on systems on which $TMPDIR != /tmp, because the inspected directory was
different from the one in which the mock files were being written. This fully
fixes the issue only partially solved in db2bc9e667a1.