Add tests for the invalid file handle detection logic in the winLock() function.
Add extra checking of the database extended error code.