Added delay parameter to wait_for function

Added delay parameter to wait_for function
Added wait_for test