Added tests and example for semaphore