diff --git a/README.txt b/README.txt
index f4f6978..e32688d 100644
--- a/README.txt
+++ b/README.txt
@@ -128,7 +128,7 @@ behavior:
    when performing LUKE queries (for performance reasons).
 
  - apachesolr_tags_to_index: the list of HTML tags that the module will index
-   (see apachesolr_add_tags_to_document()).
+   (see apachesolr_index_add_tags_to_document()).
 
  - apachesolr_exclude_nodeapi_types: an array of node types each of which is
    an array of one or more module names, such as 'comment'.  Any type listed
diff --git a/apachesolr.index.inc b/apachesolr.index.inc
index 252c1de..ea1cb7f 100644
--- a/apachesolr.index.inc
+++ b/apachesolr.index.inc
@@ -271,9 +271,6 @@ function apachesolr_index_entity_to_documents($item, $env_id) {
     if (empty($document->teaser)) {
       $document->teaser = truncate_utf8($document->content, 300, TRUE);
     }
-
-    // Add additional indexing based on the body of each record.
-    apachesolr_index_add_tags_to_document($document, $document->content);
   }
 
   // Now allow modules to alter each other's additions for maximum flexibility.
@@ -344,15 +341,7 @@ function apachesolr_index_send_to_solr($env_id, array $documents) {
   }
 }
 
-/**
- * Extract HTML tag contents from $text and add to boost fields.
- *
- * @param ApacheSolrDocument $document
- * @param string $text
- *   must be stripped of control characters before hand.
- *
- */
-function apachesolr_index_add_tags_to_document(ApacheSolrDocument $document, $text) {
+function _apachesolr_tags_to_index() {
   $tags_to_index = variable_get('apachesolr_tags_to_index', array(
     'h1' => 'tags_h1',
     'h2' => 'tags_h2_h3',
@@ -367,9 +356,23 @@ function apachesolr_index_add_tags_to_document(ApacheSolrDocument $document, $te
     'em' => 'tags_inline',
     'a' => 'tags_a'
   ));
+  return $tags_to_index;
+}
+
+/**
+ * Extract HTML tag contents from $text and add to boost fields.
+ *
+ * @param ApacheSolrDocument $document
+ * @param string $text
+ *   must be stripped of control characters before hand.
+ *
+ */
+function apachesolr_index_add_tags_to_document(ApacheSolrDocument $document, $text) {
+  $tags_to_index = _apachesolr_tags_to_index();
 
   // Strip off all ignored tags.
-  $text = strip_tags($text, '<' . implode('><', array_keys($tags_to_index)) . '>');
+  $allowed_tags = '<' . implode('><', array_keys($tags_to_index)) . '>';
+  $text = strip_tags($text, $allowed_tags);
 
   preg_match_all('@<(' . implode('|', array_keys($tags_to_index)) . ')[^>]*>(.*)</\1>@Ui', $text, $matches);
   foreach ($matches[1] as $key => $tag) {
@@ -843,6 +846,9 @@ function apachesolr_index_node_solr_document(ApacheSolrDocument $document, $node
     $document->tos_content_extra = apachesolr_clean_text(implode(' ', $extra));
   }
 
+  // Add additional indexing based on the body of each record.
+  apachesolr_index_add_tags_to_document($document, $text);
+
   //  Generic use case for future reference. Callbacks can
   //  allow you to send back multiple documents
   $documents = array();
@@ -1284,46 +1290,6 @@ function apachesolr_entityreference_indexing_callback($entity, $field_name, $ind
 }
 
 /**
- * Extract HTML tag contents from $text and add to boost fields.
- *
- * $text must be stripped of control characters before hand.
- *
- * @param ApacheSolrDocument $document
- * @param type $text
- */
-function apachesolr_add_tags_to_document(ApacheSolrDocument $document, $text) {
-  $tags_to_index = variable_get('apachesolr_tags_to_index', array(
-    'h1' => 'tags_h1',
-    'h2' => 'tags_h2_h3',
-    'h3' => 'tags_h2_h3',
-    'h4' => 'tags_h4_h5_h6',
-    'h5' => 'tags_h4_h5_h6',
-    'h6' => 'tags_h4_h5_h6',
-    'u' => 'tags_inline',
-    'b' => 'tags_inline',
-    'i' => 'tags_inline',
-    'strong' => 'tags_inline',
-    'em' => 'tags_inline',
-    'a' => 'tags_a'
-  ));
-
-  // Strip off all ignored tags.
-  $text = strip_tags($text, '<' . implode('><', array_keys($tags_to_index)) . '>');
-
-  preg_match_all('@<(' . implode('|', array_keys($tags_to_index)) . ')[^>]*>(.*)</\1>@Ui', $text, $matches);
-  foreach ($matches[1] as $key => $tag) {
-    $tag = strtolower($tag);
-    // We don't want to index links auto-generated by the url filter.
-    if ($tag != 'a' || !preg_match('@(?:http://|https://|ftp://|mailto:|smb://|afp://|file://|gopher://|news://|ssl://|sslv2://|sslv3://|tls://|tcp://|udp://|www\.)[a-zA-Z0-9]+@', $matches[2][$key])) {
-      if (!isset($document->{$tags_to_index[$tag]})) {
-        $document->{$tags_to_index[$tag]} = '';
-      }
-      $document->{$tags_to_index[$tag]} .= ' ' . apachesolr_clean_text($matches[2][$key]);
-    }
-  }
-}
-
-/**
  * hook_cron() helper to try to make the index table consistent with their
  * respective entity table.
  */
diff --git a/tests/apachesolr_base.test b/tests/apachesolr_base.test
index 30a7e57..2b2a46b 100644
--- a/tests/apachesolr_base.test
+++ b/tests/apachesolr_base.test
@@ -391,7 +391,7 @@ class DrupalSolrNodeTestCase extends DrupalWebTestCase {
 
   public static function getInfo() {
     return array(
-      'name' => 'Solr Node add and deletion tests',
+      'name' => 'Solr Node add, deletion, and document building tests',
       'description' => 'Tests if we can succesfully add and delete nodes',
       'group' => 'ApacheSolr',
     );
@@ -471,6 +471,57 @@ class DrupalSolrNodeTestCase extends DrupalWebTestCase {
       $this->assertEqual($count, 0, t('No more nodes left in the node table.'));
     }
   }
+
+  function testNodeToDocument() {
+    // enable our bundles to be indexed, and clear caches
+    apachesolr_index_set_bundles('solr', 'node', array('article'));
+    entity_info_cache_clear();
+    apachesolr_environments_clear_cache();
+    $edit = array();
+    // Create a node of the type article.
+    $type = 'article';
+    $edit['uid'] = 1;
+    $edit['type'] = $type;
+    $edit['title'] = $this->randomName(16);
+    $edit['body'][LANGUAGE_NONE][0]['value'] = 'some other ORDINARY_TEXT ';
+    // Make sure the format allows all tags.
+    $edit['body'][LANGUAGE_NONE][0]['format'] = 'full_html';
+    $tags_to_index = _apachesolr_tags_to_index();
+    // Tags that are not boosted normally.
+    $other_tags = array('div' => 'tags_inline', 'span' => 'tags_inline');
+    $all_tags = $tags_to_index + $other_tags;
+    $tag_content = array();
+    foreach ($all_tags as $tag_name => $field_name) {
+      $tag_content[$tag_name] = strtoupper($tag_name) . '_TAG_CONTENT';
+      if ($tag_name == 'a') {
+        $edit['body'][LANGUAGE_NONE][0]['value'] .= "<{$tag_name} href=\"http://example.com\">{$tag_content[$tag_name]}</{$tag_name}> other filler ";
+      }
+      else {
+        $edit['body'][LANGUAGE_NONE][0]['value'] .= "<{$tag_name}>{$tag_content[$tag_name]}</{$tag_name}> dummy text ";
+      }
+    }
+    $node = $this->drupalCreateNode($edit);
+    $this->assertTrue(is_object($node) && isset($node->nid), t('Article type @type has been created.', array('@type' => $type)));
+
+    $item = new stdClass();
+    $item->entity_id = $node->nid;
+    $item->entity_type = 'node';
+    $item->bundle = $node->type;
+    $env_id = apachesolr_default_environment();
+    $docs = apachesolr_index_entity_to_documents($item, $env_id);
+    $this->assertEqual(count($docs), 1, 'Only one document from one node');
+    $document = end($docs);
+    $this->assertTrue(strpos($document->content,'ORDINARY_TEXT') !== FALSE, "Found in content field expected: ORDINARY_TEXT");
+    foreach ($tags_to_index as $tag_name => $field_name) {
+      $this->assertTrue(strpos($document->content, $tag_content[$tag_name]) !== FALSE, "Found in content field expected: {$tag_content[$tag_name]}");
+      $this->assertTrue(!empty($document->{$field_name}) && strpos($document->{$field_name}, $tag_content[$tag_name]) !== FALSE, "Found in {$field_name} field expected: {$tag_content[$tag_name]}");
+      $this->assertTrue(empty($document->{$field_name}) || strpos($document->{$field_name},'ORDINARY_TEXT') === FALSE, "NOT Found in {$field_name}: ORDINARY_TEXT");
+    }
+    foreach ($other_tags as $tag_name => $field_name) {
+      $this->assertTrue(strpos($document->content, $tag_content[$tag_name]) !== FALSE, "Found in content field expected: {$tag_content[$tag_name]}");
+      $this->assertTrue(empty($document->{$field_name}) || strpos($document->{$field_name}, $tag_content[$tag_name]) === FALSE, "NOT found in {$field_name}: {$tag_content[$tag_name]}");
+    }
+  }
 }
 
 class DrupalSolrOfflineUnitTestCase extends DrupalUnitTestCase {
diff --git a/tests/solr_document.test b/tests/solr_document.test
index 8b2a833..871d711 100644
--- a/tests/solr_document.test
+++ b/tests/solr_document.test
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Unit tests for query object methods.
+ *   Unit tests for document object methods.
  *
  *
  */
