tests: switch from tmpnam to mkstemp

Use mkstemp to generate a temporary file in a safer way than tmpnam,
and placed in the temporary home created for the tests already.
Merge pull request #44 from pinotree/tmpnam

tests: switch from tmpnam to mkstemp