Fix tempfile syntax
It's fairly safe to close the file handle before removing since the lock_file has been already exclusive locked using File::NFSLock
This allows it to be more compatible with Win32 perl.
RT#42122
Add tests with TAINT enabled.