diff --git a/modernizr.module b/modernizr.module
index 506e5d7..d01f443 100644
--- a/modernizr.module
+++ b/modernizr.module
@@ -337,32 +337,35 @@ function _modernizr_load_generate() {
     foreach ($testObjects as $load) {
       $output .= ($num_tests > 1) ? ',' : '';
       $output .= '{' . "\n";
-      $output .= '  test: ' . $load['test'] . ',' . "\n";
+      $output .= '  test: ' . $load['test'];
 
       // Print each action and its resources
       $actions = array('yep', 'nope', 'both', 'load');
+      $prefix = "\n";
       foreach ($actions as $action) {
         if (isset($load[$action])) {
 
           // Begin output for this action
-          $output .= '  ' . sprintf('%-4s', $action) . ': ';
+          $output .= $prefix.'  ' . sprintf('%-4s', $action) . ': ';
 
           // How many resources for this action?
           if (count($load[$action]) == 1) {
             // Single resource
-            $output .= "'" . $load[$action][0] . "',\n";
+            $output .= "'" . $load[$action][0] ."' ";
+            $output = substr($output, 0, -1);            
           }
           else {
             // Multiple resources
             $output .= '[';
             foreach ($load[$action] as $resource) {
-              $output .= "'" . $resource . "',";
+              $output .= "'" . $resource . "'";
             }
             // Truncate last comma
             $output = substr($output, 0, -1);
             $output .= "],\n";
           }
         }
+        $prefix = ",\n";
       }
 
       // Output these two properties without quotes around the output
