FIX: Integration Tests 040 and 041 on SLC 5

Turns out, that `mktemp` does not support `--tmpdir=` on SLC 5, thus no tmp directory is created and integration tests 040 and 041 blow up. Additionally I fixed some potential permission issues when cleaning up the created tmp directory.

**NOTE:** There was also a failure path that didn't have a `return != 0` statement. Please review carefully.