Merge pull request #3 from antoinealb/master

Check for semaphore max value.
Assserts that the semaphore is available.