diff --git a/addthis.info b/addthis.info
index 7b109a5..b0c55da 100644
--- a/addthis.info
+++ b/addthis.info
@@ -14,5 +14,6 @@ files[] = tests/AddThisDrupalSettingsJsTestHelper.php
 files[] = tests/AddThisJsTest.test
 files[] = tests/AddThisFunctionalityTestCase.test
 files[] = tests/AddThisPermissionsTestCase.test
+files[] = tests/AddThisUnitTestCase.test
 
 configure = admin/config/user-interface/addthis
diff --git a/classes/AddThis.php b/classes/AddThis.php
index 8a5f826..789f785 100644
--- a/classes/AddThis.php
+++ b/classes/AddThis.php
@@ -388,7 +388,7 @@ class AddThis {
   private function getAttributeTitle($entity) {
     if (isset($entity->title)) {
       return array(
-        self::TITLE_ATTRIBUTE => $entity->title . ' - ' . variable_get('site_name'),
+        self::TITLE_ATTRIBUTE => htmlspecialchars($entity->title . ' - ' . variable_get('site_name'), ENT_COMPAT),
       );
     }
     return array();
diff --git a/tests/AddThisUnitTestCase.test b/tests/AddThisUnitTestCase.test
new file mode 100644
index 0000000..66144d9
--- /dev/null
+++ b/tests/AddThisUnitTestCase.test
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * @file
+ * Tests for AddThis class.
+ */
+
+
+/**
+ * Test AddThis class.
+ */
+class AddThisUnitTestCase extends DrupalUnitTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'AddThis Class test',
+      'description' => 'Tests methods in AddThis class',
+      'group' => 'AddThis',
+    );
+  }
+
+  /**
+   * Tests title.
+   */
+  public function testTitle() {
+    $add_this = AddThis::getInstance();
+    $title = 'Test with & and ąęśćżłó';
+    $options = array(
+      '#entity' => (object) array(
+        'title' => $title,
+      )
+    );
+    $attributes = $add_this->getAddThisAttributesMarkup($options);
+    $this->assertTrue(strpos($attributes[AddThis::TITLE_ATTRIBUTE], $title) === 0, format_string('Rendered title !title has given title value: !original.', array('!title' => $attributes[AddThis::TITLE_ATTRIBUTE], '!origin' => $title)));
+  }
+
+}
