redesigned semaphore and lock. tests not passing