throw IllegalArgumentException if timeout is < 0 and write junit test for it