Replaced time() with uniqid() to make sure the file name is unique

The cache isn't cleared properly because unlink() doesn't remove the
cache entry which caused side-effects when reusing the same file name
(which randomly happens when time() returns the same value)

This fix first makes sure the unit tests don't fail any more.
The unlink() case with the cache will be investigated separately (CC @icewind1991 FYI)

This should fix the random errors we sometimes see on PHP533 which possibly, for some reason, returns the same time() value twice in a row more often than other versions.

Please review @DeepDiver1975 @schiesbn @karlitschek