tests: properly cleanup the temporary directories

Chmod the temporary directory again so we can clean it all, avoid
leaving stray temporary directories.

This is a kind of revert of few parts of commit
22b0662ebf64e93dc275acc1cc37ebd12cce6b49, but adapted to the unique
$tmpdir used now.