Fixed Posix locking functions for Windows

Fixed and added several Posix functions for Windows
Improvements to the test