Adding timeout to waitForState

Signed-off-by: Tsuyoshi Ozawa <ozawa.tsuyoshi@gmail.com>