fixed NPE
added timeout configuration
better way of handling InterruptedException
Merge pull request #1 from bartoszwalacik/timeouts

bugfix for always-null return