-zc.waitfor = (timeout, check) ->
+zc.waitfor = (check, timeout=1000) ->
   t0 = _.now()
   deferred = Q.defer()
 

      clearInterval(interval)
      deferred.resolve(rv)

  interval = setInterval(poll, 100)

  return deferred.promise


        messages = $history.find('.message-text').text()
        return messages if messages.length > 0

      return zc.waitfor(get_messages, 3000)
    .then (messages) ->
      expect(messages).toEqual("hello world")
    .catch (err) ->
