work on semaphore and lock. tests are broken