diff --git a/scheduler.test b/scheduler.test
index c5e91d5..06cab27 100644
--- a/scheduler.test
+++ b/scheduler.test
@@ -36,6 +36,7 @@ class SchedulerTestCase extends DrupalWebTestCase {
    */
   function setUp() {
     parent::setUp('date', 'scheduler');
+    $config = \Drupal::config('scheduler.settings');
 
     // Create a 'Basic Page' content type.
     $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
@@ -44,8 +45,9 @@ class SchedulerTestCase extends DrupalWebTestCase {
     $this->admin_user = $this->drupalCreateUser(array('access content', 'administer scheduler', 'create page content', 'edit own page content', 'delete own page content', 'view own unpublished content', 'administer nodes', 'schedule (un)publishing of nodes'));
 
     // Add scheduler functionality to the page node type.
-    variable_set('scheduler_publish_enable_page', 1);
-    variable_set('scheduler_unpublish_enable_page', 1);
+    $config->set('scheduler_publish_enable_page', 1);
+    $config->set('scheduler_unpublish_enable_page', 1);
+    $config->save();
   }
 
   /**
@@ -109,6 +111,8 @@ class SchedulerTestCase extends DrupalWebTestCase {
    * Test the different options for past publication dates.
    */
   public function testSchedulerPastDates() {
+    $config = \Drupal::config('scheduler.settings');
+
     // Log in.
     $this->drupalLogin($this->admin_user);
 
@@ -125,7 +129,7 @@ class SchedulerTestCase extends DrupalWebTestCase {
     $this->assertRaw(t("The 'publish on' date must be in the future"), 'An error message is shown when the publication date is in the past and the "error" behavior is chosen.');
 
     // Test the 'publish' behavior: the node should be published immediately.
-    variable_set('scheduler_publish_past_date_page', 'publish');
+    $config->set('scheduler_publish_past_date_page', 'publish');
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
     $this->assertNoRaw(t("The 'publish on' date must be in the future"), 'No error message is shown when the publication date is in the past and the "publish" behavior is chosen.');
     $this->assertRaw(t('@type %title has been updated.', array('@type' => t('Basic page'), '%title' => check_plain($edit['title']))), 'The node is saved successfully when the publication date is in the past and the "publish" behavior is chosen.');
@@ -136,7 +140,7 @@ class SchedulerTestCase extends DrupalWebTestCase {
 
     // Test the 'schedule' behavior: the node should be unpublished and become
     // published on the next cron run.
-    variable_set('scheduler_publish_past_date_page', 'schedule');
+    $config->set('scheduler_publish_past_date_page', 'schedule');
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
     $this->assertNoRaw(t("The 'publish on' date must be in the future"), 'No error message is shown when the publication date is in the past and the "schedule" behavior is chosen.');
     $this->assertRaw(t('@type %title has been updated.', array('@type' => t('Basic page'), '%title' => check_plain($edit['title']))), 'The node is saved successfully when the publication date is in the past and the "schedule" behavior is chosen.');
@@ -151,12 +155,16 @@ class SchedulerTestCase extends DrupalWebTestCase {
     scheduler_cron();
     $node = node_load($node->nid, NULL, TRUE);
     $this->assertTrue($node->status, 'The node with publication date in the past and the "schedule" behavior has now been published by cron.');
+
+    $config->save();
   }
 
   /**
    * Tests the creation of new revisions on scheduling.
    */
   public function testRevisioning() {
+    $config = \Drupal::config('scheduler.settings');
+
     // Create a scheduled node that is not automatically revisioned.
     $created = strtotime('-2 day');
     $settings = array(
@@ -174,8 +182,8 @@ class SchedulerTestCase extends DrupalWebTestCase {
     $this->assertRevisionCount($node->nid, 1, 'No new revision was created when a node was unpublished with revisioning disabled.');
 
     // Enable revisioning.
-    variable_set('scheduler_publish_revision_page', 1);
-    variable_set('scheduler_unpublish_revision_page', 1);
+    $config->set('scheduler_publish_revision_page', 1);
+    $config->set('scheduler_unpublish_revision_page', 1);
 
     // Test scheduled publication with revisioning enabled.
     $node = $this->schedule($node);
@@ -194,12 +202,16 @@ class SchedulerTestCase extends DrupalWebTestCase {
       '@date' => format_date(REQUEST_TIME, 'short'),
     ));
     $this->assertRevisionLogMessage($node->nid, $expected_message, 'The correct message was found in the node revision log after scheduled unpublishing.');
+
+    $config->save();
   }
 
   /**
    * Tests if options can both be displayed as extra fields and vertical tabs.
    */
   function testExtraFields() {
+    $config = \Drupal::config('scheduler.settings');
+
     $this->drupalLogin($this->admin_user);
 
     // Test if the options are shown as vertical tabs by default.
@@ -207,16 +219,18 @@ class SchedulerTestCase extends DrupalWebTestCase {
     $this->assertTrue($this->xpath('//div[contains(@class, "vertical-tabs-panes")]/fieldset[@id = "edit-scheduler-settings"]'), 'By default the scheduler options are shown as a vertical tab.');
 
     // Test if the options are shown as extra fields when configured to do so.
-    variable_set('scheduler_use_vertical_tabs_page', 0);
+    $config->set('scheduler_use_vertical_tabs_page', 0);
     $this->drupalGet('node/add/page');
     $this->assertFalse($this->xpath('//div[contains(@class, "vertical-tabs-panes")]/fieldset[@id = "edit-scheduler-settings"]'), 'The scheduler options are not shown as a vertical tab when they are configured to show as an extra field.');
     $this->assertTrue($this->xpath('//fieldset[@id = "edit-scheduler-settings" and contains(@class, "collapsed")]'), 'The scheduler options are shown as a collapsed fieldset when they are configured to show as an extra field.');
 
     // Test the option to expand the fieldset.
-    variable_set('scheduler_expand_fieldset_page', 1);
+    $config->set('scheduler_expand_fieldset_page', 1);
     $this->drupalGet('node/add/page');
     $this->assertFalse($this->xpath('//div[contains(@class, "vertical-tabs-panes")]/fieldset[@id = "edit-scheduler-settings"]'), 'The scheduler options are not shown as a vertical tab when they are configured to show as an expanded fieldset.');
     $this->assertTrue($this->xpath('//fieldset[@id = "edit-scheduler-settings" and not(contains(@class, "collapsed"))]'), 'The scheduler options are shown as an expanded fieldset.');
+
+    $config->save();
   }
 
   /**
@@ -360,6 +374,8 @@ class SchedulerTestCase extends DrupalWebTestCase {
    * Tests creating and editing nodes with required scheduling enabled.
    */
   function testRequiredScheduling() {
+    $config = \Drupal::config('scheduler.settings');
+
     $this->drupalLogin($this->admin_user);
 
     // Define test scenarios with expected results.
@@ -493,12 +509,12 @@ class SchedulerTestCase extends DrupalWebTestCase {
 
     foreach ($test_cases as $test_case) {
       // Enable required (un)publishing as stipulated by the test case.
-      variable_set('scheduler_publish_required_page', $test_case['required'] == 'publish');
-      variable_set('scheduler_unpublish_required_page', $test_case['required'] == 'unpublish');
+      $config->set('scheduler_publish_required_page', $test_case['required'] == 'publish');
+      $config->set('scheduler_unpublish_required_page', $test_case['required'] == 'unpublish');
 
       // Set the default node status, used when creating a new node.
       $node_options_page = !empty($test_case['status']) ? array('status') : array();
-      variable_set('node_options_page', $node_options_page);
+      $config->set('node_options_page', $node_options_page);
 
       // To assist viewing and analysing the generated test result pages create
       // a text string showing all the test case parameters.
@@ -545,6 +561,7 @@ class SchedulerTestCase extends DrupalWebTestCase {
           break;
       }
     }
+    $config->save();
   }
 
   /**
@@ -557,7 +574,7 @@ class SchedulerTestCase extends DrupalWebTestCase {
     $node = $this->drupalCreateNode(array('type' => 'page', 'status' => FALSE, 'title' => $this->randomName()));
 
     // Set unpublishing to be required.
-    variable_set('scheduler_unpublish_required_page', TRUE);
+    \Drupal::config('scheduler.settings')->set('scheduler_unpublish_required_page', TRUE)->save();
 
     // Edit the node and check the validation.
     $edit = array(
@@ -575,6 +592,8 @@ class SchedulerTestCase extends DrupalWebTestCase {
    * @see https://drupal.org/node/1614880
    */
   public function testScheduledNodeDelete() {
+    $config = \Drupal::config('scheduler.settings');
+
     // Log in.
     $this->drupalLogin($this->admin_user);
 
@@ -583,8 +602,8 @@ class SchedulerTestCase extends DrupalWebTestCase {
     $published_node = $this->drupalCreateNode(array('type' => 'page', 'status' => 1));
 
     // Make scheduled publishing and unpublishing required.
-    variable_set('scheduler_publish_required_page', TRUE);
-    variable_set('scheduler_unpublish_required_page', TRUE);
+    $config->set('scheduler_publish_required_page', TRUE);
+    $config->set('scheduler_unpublish_required_page', TRUE);
 
     // Check that deleting the nodes does not throw form validation errors.
     $this->drupalPost('node/' . $published_node->nid . '/edit', array(), t('Delete'));
@@ -592,6 +611,8 @@ class SchedulerTestCase extends DrupalWebTestCase {
 
     $this->drupalPost('node/' . $unpublished_node->nid . '/edit', array(), t('Delete'));
     $this->assertNoRaw(t('Error message'), 'No error messages are shown when trying to delete an unpublished node with no scheduling information.');
+
+    $config->save();
   }
 
 }
diff --git a/src/Form/SchedulerAdminForm.php b/src/Form/SchedulerAdminForm.php
index e659e08..e2d77fe 100644
--- a/src/Form/SchedulerAdminForm.php
+++ b/src/Form/SchedulerAdminForm.php
@@ -143,17 +143,16 @@ class SchedulerAdminForm extends ConfigFormBase {
     foreach (Element::children($form) as $variable) {
       $config->set($variable, $form_state->getValue($form[$variable]['#parents']));
     }
-    $config->save();
 
     // Extract the date part and time part of the full format, for use with the
     // default time functionality. Assume the date and time time parts begin and
     // end with a letter, but any punctuation between these will be retained.
     $format = $form_state->getValue(['date_format']);
     $time_only_format = $this->getTimeOnlyFormat($format);
-    variable_set('time_only_format', $time_only_format);
+    $config->set('time_only_format', $time_only_format)->save();
 
     $date_only_format = $this->getDateOnlyFormat($format);
-    variable_set('date_only_format', $date_only_format);
+    $config->set('date_only_format', $time_only_format)->save();
 
     if (empty($time_only_format)) {
       drupal_set_message(t('The date part of the Scheduler format is %date_part. There is no time part', ['%date_part' => $date_only_format]));
@@ -162,6 +161,8 @@ class SchedulerAdminForm extends ConfigFormBase {
       drupal_set_message(t('The date part of the Scheduler format is %date_part and the time part is %time_part.', ['%date_part' => $date_only_format, '%time_part' => $time_only_format]));
     }
 
+    $config->save();
+
     parent::submitForm($form, $form_state);
   }
 
diff --git a/tests/scheduler_api.test b/tests/scheduler_api.test
index a8bffe8..5f823b8 100644
--- a/tests/scheduler_api.test
+++ b/tests/scheduler_api.test
@@ -29,10 +29,13 @@ class SchedulerApiTestCase extends DrupalWebTestCase {
    */
   function setUp() {
     parent::setUp('scheduler', 'scheduler_test');
+    $config = \Drupal::config('scheduler.settings');
 
     // Add scheduler functionality to the 'scheduler_test' node type.
-    variable_set('scheduler_publish_enable_scheduler_test', 1);
-    variable_set('scheduler_unpublish_enable_scheduler_test', 1);
+    $config->set('scheduler_publish_enable_scheduler_test', 1);
+    $config->set('scheduler_unpublish_enable_scheduler_test', 1);
+
+    $config->save();
   }
 
   /**
@@ -61,7 +64,7 @@ class SchedulerApiTestCase extends DrupalWebTestCase {
 
     // Turn on immediate publication of nodes with publication dates in the past
     // and repeat the tests. It is not needed to simulate cron runs now.
-    variable_set('scheduler_publish_past_date_scheduler_test', 'publish');
+    \Drupal::config('scheduler.settings')->set('scheduler_publish_past_date_scheduler_test', 'publish')->save();
     $node = $this->createUnapprovedNode();
     $this->assertNodeNotPublished($node->nid, 'An unapproved node is not published immediately after saving.');
     $this->approveNode($node->nid);
