diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test
index e28b684305664c9229a232139c14743ec59f050f..8bf2188d201ba10aeed2530ebdcab5d488b6df41 100644
--- a/modules/simpletest/simpletest.test
+++ b/modules/simpletest/simpletest.test
@@ -232,7 +232,7 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
     $fieldsets = $this->xpath('//fieldset');
     $info = $this->getInfo();
     foreach ($fieldsets as $fieldset) {
-      if ($fieldset->legend == $info['name']) {
+      if ($this->asText($fieldset->legend) == $info['name']) {
         return $fieldset;
       }
     }
diff --git a/themes/seven/style.css b/themes/seven/style.css
index 12848cf87278e4f627630664b7fe896a4a029bd6..07ccb7d4b35efee7fb9b336fa8ab8f5a65f1cf33 100644
--- a/themes/seven/style.css
+++ b/themes/seven/style.css
@@ -443,14 +443,35 @@ table tr.selected td {
 /* Fieldsets & Form items */
 fieldset {
   border: 1px solid #ccc;
-  padding: 9px;
+  padding: 30px 13px 13px 14px;
   margin: 0 0 10px;
 }
 
+fieldset legend span,
+fieldset legend a {
+  position: absolute;
+  margin-top: 9px;
+}
+
+fieldset legend a span {
+  position: relative;
+  margin-top: 0;
+}
+
 fieldset.collapsed {
   background: transparent;
 }
 
+html.js fieldset.collapsed legend,
+html.js fieldset.collapsed legend * {
+  display: block;
+}
+html.js fieldset.collapsed {
+  border-width: 1px;
+  margin-bottom: 10px;
+  padding: 13px;
+}
+
 fieldset fieldset {
   background: #fff;
 }
diff --git a/themes/seven/template.php b/themes/seven/template.php
index 701b54c2a1c6b46477571a5b712a262b516e79a3..9fd97f12fd3bd2bf17b371e9631f57b3e1de2aab 100644
--- a/themes/seven/template.php
+++ b/themes/seven/template.php
@@ -65,3 +65,26 @@ function seven_tablesort_indicator($style) {
     return theme('image', $theme_path . '/images/arrow-desc.png', t('sort icon'), t('sort descending'));
   }
 }
+
+/**
+ * Override of theme_fieldset().
+ *
+ * Add span to legend tag, so we can style it to be inside the fieldset.
+ */
+function seven_fieldset($element) {
+  if (!empty($element['#collapsible'])) {
+    drupal_add_js('misc/collapse.js');
+
+    if (!isset($element['#attributes']['class'])) {
+      $element['#attributes']['class'] = '';
+    }
+
+    $element['#attributes']['class'] .= ' collapsible';
+    if (!empty($element['#collapsed'])) {
+      $element['#attributes']['class'] .= ' collapsed';
+    }
+  }
+  $element['#attributes']['id'] = $element['#id'];
+
+  return '<fieldset' . drupal_attributes($element['#attributes']) . '>' . ($element['#title'] ? '<legend><span>' . $element['#title'] . '</span></legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="fieldset-description">' . $element['#description'] . '</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . (isset($element['#value']) ? $element['#value'] : '') . "</fieldset>\n";
+}