unit test for Semaphore

fixed failed test

cleaned code