diff --git a/core/lib/Drupal/Component/Serialization/Yaml.php b/core/lib/Drupal/Component/Serialization/Yaml.php
index 7d0f0c5..5e104ba 100644
--- a/core/lib/Drupal/Component/Serialization/Yaml.php
+++ b/core/lib/Drupal/Component/Serialization/Yaml.php
@@ -8,7 +8,8 @@
 namespace Drupal\Component\Serialization;
 
 use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
-use Symfony\Component\Yaml\Yaml as Symfony;
+use Symfony\Component\Yaml\Parser;
+use Symfony\Component\Yaml\Dumper;
 
 /**
  * Default serialization for YAML using the Symfony component.
@@ -20,7 +21,9 @@ class Yaml implements SerializationInterface {
    */
   public static function encode($data) {
     try {
-      return Symfony::dump($data, PHP_INT_MAX, 2, TRUE);
+      $yaml = new Dumper();
+      $yaml->setIndentation(2);
+      return $yaml->dump($data, PHP_INT_MAX, 0, TRUE, FALSE);
     }
     catch (\Exception $e) {
       throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
@@ -32,7 +35,10 @@ public static function encode($data) {
    */
   public static function decode($raw) {
     try {
-      return Symfony::parse($raw, TRUE);
+      $yaml = new Parser();
+      // Make sure we have a single trailing newline. A very simple config like
+      // 'foo: bar' with no newline will fail to parse otherwise.
+      return $yaml->parse($raw, TRUE, FALSE);
     }
     catch (\Exception $e) {
       throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php
new file mode 100644
index 0000000..94269e6
--- /dev/null
+++ b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\Component\Serialization\YamlTest.
+ */
+
+namespace Drupal\Tests\Component\Serialization;
+
+use Drupal\Component\Serialization\Yaml;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * @coversDefaultClass \Drupal\Component\Serialization\Yaml
+ * @group Serialization
+ */
+class YamlTest extends UnitTestCase {
+
+  /**
+   * @covers ::decode
+   */
+  public function testDecode() {
+    // Test that files without line break endings are properly interpreted.
+    $yaml = 'foo: bar';
+    $expected = array(
+      'foo' => 'bar',
+    );
+    $this->assertSame($expected, Yaml::decode($yaml));
+    $yaml .= "\n";
+    $this->assertSame($expected, Yaml::decode($yaml));
+    $yaml .= "\n";
+    $this->assertSame($expected, Yaml::decode($yaml));
+
+    $yaml = "{}\n";
+    $expected = array();
+    $this->assertSame($expected, Yaml::decode($yaml));
+
+    $yaml = '';
+    $this->assertNULL(Yaml::decode($yaml));
+    $yaml .= "\n";
+    $this->assertNULL(Yaml::decode($yaml));
+    $yaml .= "\n";
+    $this->assertNULL(Yaml::decode($yaml));
+  }
+
+  /**
+   * @covers ::encode
+   */
+  public function testEncode() {
+    $decoded = array(
+      'foo' => 'bar',
+    );
+    $this->assertSame('foo: bar' . "\n", Yaml::encode($decoded));
+  }
+
+  /**
+   * @covers ::getFileExtension
+   */
+  public function testGetFileExtension() {
+    $this->assertEquals('yml', Yaml::getFileExtension());
+  }
+
+}
