diff --git a/tests/title.test b/tests/title.test
index b58635e..e88eb52 100644
--- a/tests/title.test
+++ b/tests/title.test
@@ -162,18 +162,25 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('field_test', 'title', 'title_test');
+    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy'));
+    $this->drupalLogin($admin_user);
   }
 
   /**
    * Check for automated title_field attachment.
    */
   function testAutomatedFieldAttachement() {
-    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy'));
-    $this->drupalLogin($admin_user);
+    $this->assertAutomatedFieldAttachement(TRUE);
+    $this->assertAutomatedFieldAttachement(FALSE);
+  }
 
+  /**
+   * Check that the fields are replaced or skipped depdening on the given value.
+   */
+  function assertAutomatedFieldAttachement($enabled) {
     $edit = array(
-      'title_taxonomy_term[auto_attach][name]' => TRUE,
-      'title_taxonomy_term[auto_attach][description]' => TRUE,
+      'title_taxonomy_term[auto_attach][name]' => $enabled,
+      'title_taxonomy_term[auto_attach][description]' => $enabled,
     );
     $this->drupalPost('admin/config/content/title', $edit, t('Save configuration'));
 
@@ -187,8 +194,8 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
     $entity_type = 'taxonomy_term';
     $bundle = $edit['machine_name'];
     field_info_cache_clear();
-    $this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name'), 'Name field automatically attached.');
-    $this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description', 'Description field automatically attached.'));
+    $this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name') == $enabled, 'Name field correctly processed.');
+    $this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description') == $enabled, 'Description field correctly processed.');
   }
 }
 
diff --git a/title.module b/title.module
index d0339f6..06b6b3a 100644
--- a/title.module
+++ b/title.module
@@ -243,7 +243,6 @@ function title_field_replacement_enabled($entity_type, $bundle, $legacy_field) {
  */
 function title_field_replacement_toggle($entity_type, $bundle, $legacy_field) {
   $info = title_field_replacement_info($entity_type, $legacy_field);
-
   if (!$info) {
     return;
   }
@@ -829,24 +828,26 @@ function title_field_attach_create_bundle($entity_type, $bundle) {
 
   $options = variable_get('title_' . $entity_type, array());
 
-  foreach (array_keys($entity_info['field replacement']) as $field_name) {
-    if (!isset($options['auto_attach'][$field_name])) {
+  foreach (array_keys($entity_info['field replacement']) as $legacy_field) {
+    if (empty($options['auto_attach'][$legacy_field])) {
       continue;
     }
 
     // Do not continue if the replacement field already exists.
+    $field_name = $entity_info['field replacement'][$legacy_field]['field']['field_name'];
     if (field_info_instance($entity_type, $field_name, $bundle)) {
       continue;
     }
 
-    title_field_replacement_toggle($entity_type, $bundle, $field_name);
+    title_field_replacement_toggle($entity_type, $bundle, $legacy_field);
 
     $instance = field_info_instance($entity_type, $field_name, $bundle);
-    $params = array(
-      '@entity_label' => drupal_strtolower($entity_info['label']),
-      '%field_name' => t($entity_info['field replacement'][$field_name]['instance']['label']),
-     );
-
-    drupal_set_message(t('The @entity_label %field_name field was automatically replaced.', $params));
+    if ($instance) {
+      $params = array(
+        '@entity_label' => drupal_strtolower($entity_info['label']),
+        '%field_name' => $instance['label'],
+      );
+      drupal_set_message(t('The @entity_label %field_name field was automatically replaced.', $params));
+    }
   }
 }
