Bugfix:  Fix Semaphore.wait() is always instant.

`Semaphore.wait()` never blocks even when the semaphore is locked, because `Semaphore.acquire()` forgets to clear the `_unlocked` event.

Test case for `Semaphore.wait()` is added too.