extracting mkdtemp code into MakeTemporaryDirectory()

We'll use this elsewhere.
fix bug where otest-query will fail with ...

```
Failed to query the list of test cases in the test bundle: Error while
parsing JSON: The data is not in the correct format.:
```

See included comment for more info.