 
   async: (fn) ->
     Testify.count++
-    @emitter.once "done", =>
+    @emitter.once "done", ->
       Testify.count--
+
     try
       fn(@)
     catch error

    @failed = error
    if @parent
      @parent.fail(true)

  done: () ->
    @emitter.emit("done")

  success: (description) ->
    console.log description.green

  assert: require("assert")

  pass: (description) ->
    @emitter.once "done", => @success("  * " + description)

  #fail: (description, error) ->
    #if !error
      #console.log "Failed: #{@name}\n  => #{description}".red.bold
    #else
      #if error.constructor == String || error.name == "AssertionError"
        #console.log "Failed: #{@name}\n  * #{description} => #{error}".red.bold
      #else
        #console.log colors.yellow("Error: '#{description}' => #{error}")
      # split,slice to remove the error message from the stack trace
      #if error.stack
        #console.log colors.white(error.stack.split("\n").slice(1).join("\n"))

  #fail: (error) ->
    #if error.constructor == String || error.name == "AssertionError"
      #console.log "Failed: #{@name}\n => #{error}".red.bold
    #else
      #console.log colors.yellow("Error: '#{description}' => #{error}")


      indent = indent + "    " while level--

      if test.failed == false
        line = indent + test.name.green
      else if test.failed == true
        line = indent + "#{test.name} - subtest failures".red
      else if test.failed.constructor == String || test.failed.name == "AssertionError"
        line = indent + "#{test.name} - #{test.failed}".red
      else
        line = indent + "#{test.name} - #{test.failed}".yellow
      console.log(line)
    console.log()

  collect: (array=[]) ->
    array.push(@)
    for context in @children
      context.collect(array)

  test: (description, fn) ->
    context = new Context(description, @)
