Add wait timeout

Added wait timeout. Sometimes for unknown reason, this function does not return at all. Timeout throws error instead of running forever.
Merge pull request #2 from ddsol/patch-1

Add wait timeout