Fixed unit tests writing to root

Depending on the implementation, `tmpnam()` might return a unique filename for the current working directory only, which would still be prefixed by `/` or `\` (but no absolute path).

For example, when using MSVC 2013, a temporary filename returned might be `/abc1.2`. The path won't be accessible without elevated rights.

The updated code using `tempnam()` works similar, although it will return a full path (tested with MSVC 2013 as well as with GCC 4.8.1).