   log: console.log.bind console
   __finished__: cb
 
-interalDefinition = (api) ->
-  _.reduce api.internal, ((acc, i, fname) ->
+snippetsDefinition = (api) ->
+  _.reduce api.snippets, ((acc, i, fname) ->
     "#{acc}\nvar #{fname} = #{i}"), ""
 
 allRemotes = (api) ->

  run: (code, customApi = {}) ->
    id = uuid.v4()

    internals = interalDefinition customApi
    remotes = allRemotes customApi

    remoteApi = customApi.links
    internalApi = _.keys customApi.internal

    apiArgs = (_.union remoteApi, internalApi).join ","

    evalCode = """
      var runTests = function(#{apiArgs}){#{code}};
      var start = function(application){ #{remotes};#{internals};runTests(#{apiArgs})};
      start
    """


      runner customApi

      # is synchronous so.. its finished here
      customApi.remote?.finished?()
    catch e
      customApi.remote?.failed? e

  debug: (code, customApi, cbs) ->
    debugApi = _.union [(code) -> "debugger;\n#{code}"], customApi
