Improve handling of temporary test folders

Previously when two builds were running tests concurrently they used
the same temporary directory, causing random test failures because
one of the builds deleted the directory that the other one still
needed. This patch modifies the behavior so that a random directory
name is used.

Change-Id: I4c80e8d86a1218a4b9429dee68f30f7140b9aee1