Screw.Unit(function() {
  before(function() {
    $('dom_test').empty();
  });

  Screw.Unit.it_behaves_like_a_method_with_callback_protection = function(action) {
    it("throws an exception", function() {
      var message = '';
      try {
        action();
      } catch(e) {
        message = e
      }
      expect(message).to(equal, 'callback needs to be a function, it was: null');
    });
  }

  Screw.Unit.enumerableContext = function(callStatic, callIterator, context) {
    var toArray = function() {
      var result = []
      for (var i = 0; i < this.length; i++)
        result.push(this[i])
      return(result)
    }

    var describeStaticAndIterator = function(def) {
      describe("static function",   function() { def(callStatic) });
      describe("iterator function", function() { def(callIterator) });
    }

    enumerableHelpers = {
      it_protects_from_invalid_callback: function() { 
        var extraArguments = toArray.apply(arguments);

        describe("given a callback that is not callable", function () {
          describeStaticAndIterator(function (f) {
            Screw.Unit.it_behaves_like_a_method_with_callback_protection(function() { 
              f.apply(this, [[]].concat(extraArguments.concat([null]))); 
            });
          });
        });
      },

      expect_result: function(description, expected, f) {
        describeStaticAndIterator(function(x) {
          it(description, function() {
            expect(f(x)).to(equal, expected);
          });
        });
      }
    }
    var contents = context.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];

    fn = new Function("with (enumerableHelpers) { " + contents.toString() + "}");
    fn();
  }
});

@@ -77,331 +77,8 @@
 );%0A%0A
-  Screw.Unit.it_behaves_like_a_method_with_callback_protection = function(action) %7B%0A    it(%22throws an exception%22, function() %7B%0A      var message = '';%0A      try %7B%0A        action();%0A      %7D catch(e) %7B%0A        message = e%0A      %7D%0A      expect(message).to(equal, 'callback needs to be a function, it was: null');%0A    %7D);%0A  %7D%0A%0A
   Sc
@@ -781,69 +781,34 @@
     
-Screw.Unit.it_behaves_like_a_method_with_callback_protec
+it(%22throws an excep
 tion
-(
+%22, 
 func
@@ -807,34 +807,87 @@
 n%22, function() %7B
- 
 %0A
+              var message = '';%0A              try %7B%0A  
               f.
@@ -944,16 +944,177 @@
 l%5D))); %0A
+              %7D catch(e) %7B%0A                message = e%0A              %7D%0A              expect(message).to(equal, 'callback needs to be a function, it was: null');%0A
         

Remove a level of indirection