diff --git a/lib/base.php b/lib/base.php
index 887499b58a52d7af2b7b5525390682774543ef66..aee1698e222233989e36facb8fbe2c489bad86f1 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -142,7 +142,7 @@ class OC {
 				'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'],
 			],
 		];
-		$fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig()));
+		$fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config)));
 		$scriptName = $fakeRequest->getScriptName();
 		if (substr($scriptName, -1) == '/') {
 			$scriptName .= 'index.php';
@@ -522,7 +522,7 @@ class OC {
 		}
 
 		// setup the basic server
-		self::$server = new \OC\Server(\OC::$WEBROOT);
+		self::$server = new \OC\Server(\OC::$WEBROOT, self::$config);
 		\OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd);
 		\OC::$server->getEventLogger()->start('boot', 'Initialize');
 
diff --git a/lib/private/server.php b/lib/private/server.php
index 8439500706daaf53b9af61419349c7c07cf198a6..3e1af0310d1a95f971f89e6a52571c85bc9b6ae2 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -84,8 +84,9 @@ class Server extends SimpleContainer implements IServerContainer {
 
 	/**
 	 * @param string $webRoot
+	 * @param \OC\Config $config
 	 */
-	public function __construct($webRoot) {
+	public function __construct($webRoot, \OC\Config $config) {
 		parent::__construct();
 		$this->webRoot = $webRoot;
 
@@ -238,8 +239,8 @@ class Server extends SimpleContainer implements IServerContainer {
 				$c->getSystemConfig()
 			);
 		});
-		$this->registerService('SystemConfig', function ($c) {
-			return new \OC\SystemConfig();
+		$this->registerService('SystemConfig', function ($c) use ($config) {
+			return new \OC\SystemConfig($config);
 		});
 		$this->registerService('AppConfig', function ($c) {
 			return new \OC\AppConfig(\OC_DB::getConnection());
diff --git a/lib/private/systemconfig.php b/lib/private/systemconfig.php
index d2ceeb8272d996fb9375a31a814c145ae453719c..fb8c18123d72400143c0e7178a75a65181781a46 100644
--- a/lib/private/systemconfig.php
+++ b/lib/private/systemconfig.php
@@ -44,12 +44,19 @@ class SystemConfig {
 		'objectstore' => ['arguments' => ['password' => true]],
 	];
 
+	/** @var Config */
+	private $config;
+
+	public function __construct(Config $config) {
+		$this->config = $config;
+	}
+
 	/**
 	 * Lists all available config keys
 	 * @return array an array of key names
 	 */
 	public function getKeys() {
-		return \OC::$config->getKeys();
+		return $this->config->getKeys();
 	}
 
 	/**
@@ -59,7 +66,7 @@ class SystemConfig {
 	 * @param mixed $value the value that should be stored
 	 */
 	public function setValue($key, $value) {
-		\OC::$config->setValue($key, $value);
+		$this->config->setValue($key, $value);
 	}
 
 	/**
@@ -69,7 +76,7 @@ class SystemConfig {
 	 *                       If value is null, the config key will be deleted
 	 */
 	public function setValues(array $configs) {
-		\OC::$config->setValues($configs);
+		$this->config->setValues($configs);
 	}
 
 	/**
@@ -80,7 +87,7 @@ class SystemConfig {
 	 * @return mixed the value or $default
 	 */
 	public function getValue($key, $default = '') {
-		return \OC::$config->getValue($key, $default);
+		return $this->config->getValue($key, $default);
 	}
 
 	/**
@@ -106,7 +113,7 @@ class SystemConfig {
 	 * @param string $key the key of the value, under which it was saved
 	 */
 	public function deleteValue($key) {
-		\OC::$config->deleteKey($key);
+		$this->config->deleteKey($key);
 	}
 
 	/**
diff --git a/tests/lib/allconfig.php b/tests/lib/allconfig.php
index ca3dce12eaffbbd2fff793318dccb21b5f363c79..0caf8163cfcba04f530be5f624c9723baee9c122 100644
--- a/tests/lib/allconfig.php
+++ b/tests/lib/allconfig.php
@@ -28,7 +28,9 @@ class TestAllConfig extends \Test\TestCase {
 			$connection = $this->connection;
 		}
 		if($systemConfig === null) {
-			$systemConfig = $this->getMock('\OC\SystemConfig');
+			$systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+				->disableOriginalConstructor()
+				->getMock();
 		}
 		return new \OC\AllConfig($systemConfig, $connection);
 	}
@@ -89,7 +91,9 @@ class TestAllConfig extends \Test\TestCase {
 
 	public function testSetUserValueWithPreCondition() {
 		// mock the check for the database to run the correct SQL statements for each database type
-		$systemConfig = $this->getMock('\OC\SystemConfig');
+		$systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+			->disableOriginalConstructor()
+			->getMock();
 		$systemConfig->expects($this->once())
 			->method('getValue')
 			->with($this->equalTo('dbtype'),
@@ -133,7 +137,9 @@ class TestAllConfig extends \Test\TestCase {
 	 */
 	public function testSetUserValueWithPreConditionFailure() {
 		// mock the check for the database to run the correct SQL statements for each database type
-		$systemConfig = $this->getMock('\OC\SystemConfig');
+		$systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+			->disableOriginalConstructor()
+			->getMock();
 		$systemConfig->expects($this->once())
 			->method('getValue')
 			->with($this->equalTo('dbtype'),
@@ -394,7 +400,9 @@ class TestAllConfig extends \Test\TestCase {
 
 	public function testGetUsersForUserValue() {
 		// mock the check for the database to run the correct SQL statements for each database type
-		$systemConfig = $this->getMock('\OC\SystemConfig');
+		$systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+			->disableOriginalConstructor()
+			->getMock();
 		$systemConfig->expects($this->once())
 			->method('getValue')
 			->with($this->equalTo('dbtype'),
diff --git a/tests/lib/server.php b/tests/lib/server.php
index 6b569e77dd9624c33bdf1dfe0a1dea6bad097591..e2670061e8d67c588749d315516fb88668574e3b 100644
--- a/tests/lib/server.php
+++ b/tests/lib/server.php
@@ -38,7 +38,8 @@ class Server extends \Test\TestCase {
 
 	public function setUp() {
 		parent::setUp();
-		$this->server = new \OC\Server('');
+		$config = new \OC\Config(\OC::$configDir);
+		$this->server = new \OC\Server('', $config);
 	}
 
 	public function dataTestQuery() {