/*jslint browser: true, indent: 2, nomen: true */
/*global phantom, require, console, $, _, simplerStyle, jasmine, describe, it, expect */
(function () {
  "use strict";

  phantom.injectJs('./vendor/underscore-1.4.2.js');
  phantom.injectJs('./vendor/jasmine-1.3.1/jasmine.js');
  phantom.injectJs('./vendor/phantom-jasmine/console-runner.js');
  jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());

  var fs = require('fs'),
    webpage = require('webpage'),
    scenarios = _.map(
      _.filter(
        fs.list(fs.workingDirectory + fs.separator + 'test'),
        function (filename) { return filename.match(/\.html$/); }
      ),
      function (filename) {
        return fs.absolute('test' + fs.separator + filename);
      }
    ),
    scenariosLoaded = 0;

  function runTestsAfterScenariosLoaded() {
    if (scenariosLoaded === scenarios.length) {
      var oldCallback = jasmine.getEnv().currentRunner().finishCallback;
      jasmine.getEnv().currentRunner().finishCallback = function () {
        oldCallback.apply(this, arguments);
        phantom.exit();
      };
      jasmine.getEnv().execute();
    }
  }

  _.each(scenarios, function (scenario) {
    var page = webpage.create();
    page.open(scenario, function (status) {
      var expected, calculated;

      page.injectJs("vendor/jquery-1.8.2.js");
      page.injectJs("vendor/underscore-1.4.2.js");
      page.injectJs('lib/css.js');

      expected = page.evaluate(function () {
        return window.expectedStyle;
      });
      calculated = page.evaluate(function () {
        return window.simplerStyle();
      });

      describe(scenario, function () {
        it("should see expected style", function () {
          expect(expected).toEqual(calculated);
        });
      });

      scenariosLoaded += 1;
      runTestsAfterScenariosLoaded();
    });
  });
}());

@@ -412,16 +412,21 @@
  var fs 
+     
 = requir
@@ -438,23 +438,25 @@
 '),%0A    
-webpage
+resource 
  = requi
@@ -459,23 +459,33 @@
 equire('
-webpage
+./lib/resource.js
 '),%0A    
@@ -1194,253 +1194,74 @@
     
-var page = webpage.create();%0A    page.open(scenario, function (status) %7B%0A      var expected, calculated;%0A%0A      page.injectJs(%22vendor/jquery-1.8.2.js%22);%0A      page.injectJs(%22vendor/underscore-1.4.2.js%22);%0A      page.injectJs('lib/css.js');%0A%0A     
+resource.loadWithLibs(scenario, false, function (page) %7B%0A      var
  exp
@@ -1296,32 +1296,34 @@
 on () %7B%0A        
+  
 return window.ex
@@ -1337,28 +1337,32 @@
 tyle;%0A      
-%7D);%0A
+  %7D),%0A  
       calcul
@@ -1396,32 +1396,34 @@
 on () %7B%0A        
+  
 return window.si
@@ -1432,24 +1432,26 @@
 lerStyle();%0A
+  
       %7D);%0A%0A 

Use helpers in test