[New] added test to check acquiring locks

Added a test which checks that a TX fails if a lock can not be acquired,
but succeeds before the timeout to acquire the lock is exceeded.

Further fixed the brittle tests by using a different semaphore to
synchronize the threads.