diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index b2dea2f653826e5773d06a57c7e44db76c40fe37..de7ae38b173e26e138c482cf11163587645c8ef0 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -35,6 +35,7 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
 	
 	function setUp() {
         // reset backend
+        \OC_User::clearBackends();
         \OC_User::useBackend('database');
 
         // set content for encrypting / decrypting in tests
@@ -58,17 +59,26 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
         $userHome = \OC_User::getHome($this->userId);
         $this->dataDir = str_replace('/'.$this->userId, '', $userHome);
 
-        \OC\Files\Filesystem::init($this->userId, '/');
-        \OC\Files\Filesystem::mount( 'OC_Filestorage_Local', array('datadir' => $this->dataDir), '/' );
+        // Filesystem related hooks
+        \OCA\Encryption\Helper::registerFilesystemHooks();
+
+        \OC_FileProxy::register(new OCA\Encryption\Proxy());
+
+        \OC_Util::tearDownFS();
+        \OC_User::setUserId('');
+        \OC\Files\Filesystem::setView(false);
+        \OC_Util::setupFS($this->userId);
+        \OC_User::setUserId($this->userId);
 
         $params['uid'] = $this->userId;
         $params['password'] = $this->pass;
         OCA\Encryption\Hooks::login($params);
+
 	}
 	
 	function tearDown() {
 
-	}
+    }
 
     function testGenerateKey() {
 	
@@ -272,7 +282,7 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
 		$this->assertEquals( $this->dataShort, $manualDecrypt );
 
         // Teardown
-        $this->view->unlink( $filename );
+        $this->view->unlink( $this->userId . '/files/' . $filename );
 
         Encryption\Keymanager::deleteFileKey( $this->view, $this->userId, $filename );
 	}
@@ -350,7 +360,7 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
 		
 		// Teardown
 		
-		$this->view->unlink( $filename );
+		$this->view->unlink( $this->userId . '/files/' . $filename );
 		
 		Encryption\Keymanager::deleteFileKey( $this->view, $this->userId, $filename );
 		
@@ -368,15 +378,14 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
 		
 		// Test that data was successfully written
 		$this->assertTrue( is_int( $cryptedFile ) );
-		
-		
-		// Get file contents without using any wrapper to get it's actual contents on disk
-		$retreivedCryptedFile = $this->view->file_get_contents( $this->userId . '/files/' . $filename );
-		
-		$decrypt = file_get_contents( 'crypt://' . $filename );
+
+        // Get file decrypted contents
+        $decrypt = file_get_contents( 'crypt://' . $filename );
 		
 		$this->assertEquals( $this->dataShort, $decrypt );
-		
+
+        // tear down
+        $this->view->unlink( $this->userId . '/files/' . $filename );
 	}
 	
 	function testSymmetricStreamDecryptLongFileContent() {
@@ -388,15 +397,14 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
 		
 		// Test that data was successfully written
 		$this->assertTrue( is_int( $cryptedFile ) );
-		
-		
-		// Get file contents without using any wrapper to get it's actual contents on disk
-		$retreivedCryptedFile = $this->view->file_get_contents( $this->userId . '/files/' . $filename );
-		
+
+        // Get file decrypted contents
 		$decrypt = file_get_contents( 'crypt://' . $filename );
-		
+
 		$this->assertEquals( $this->dataLong, $decrypt );
-		
+
+        // tear down
+        $this->view->unlink( $this->userId . '/files/' . $filename );
 	}
 	
 	// Is this test still necessary?
@@ -623,6 +631,65 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
 		
 	}
 
+    function testRenameFile() {
+
+        $filename = 'tmp-'.time();
+
+        // Save long data as encrypted file using stream wrapper
+        $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataLong );
+
+        // Test that data was successfully written
+        $this->assertTrue( is_int( $cryptedFile ) );
+
+        // Get file decrypted contents
+        $decrypt = file_get_contents( 'crypt://' . $filename );
+
+        $this->assertEquals( $this->dataLong, $decrypt );
+
+        $newFilename = 'tmp-new-'.time();
+        $view = new \OC\Files\View('/' . $this->userId . '/files');
+        $view->rename( $filename, $newFilename );
+
+        // Get file decrypted contents
+        $newDecrypt = file_get_contents( 'crypt://' . $newFilename );
+
+        $this->assertEquals( $this->dataLong, $newDecrypt );
+
+        // tear down
+        $view->unlink( $newFilename );
+    }
+
+    function testMoveFileIntoFolder() {
+
+        $filename = 'tmp-'.time();
+
+        // Save long data as encrypted file using stream wrapper
+        $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataLong );
+
+        // Test that data was successfully written
+        $this->assertTrue( is_int( $cryptedFile ) );
+
+        // Get file decrypted contents
+        $decrypt = file_get_contents( 'crypt://' . $filename );
+
+        $this->assertEquals( $this->dataLong, $decrypt );
+
+        $newFolder = '/newfolder1';
+        $newFilename = 'tmp-new-'.time();
+        $view = new \OC\Files\View('/' . $this->userId . '/files');
+        $view->mkdir($newFolder);
+        $view->rename( $filename, $newFolder . '/' . $newFilename );
+
+        // Get file decrypted contents
+        $newDecrypt = file_get_contents( 'crypt://' . $newFolder . '/' . $newFilename );
+
+        $this->assertEquals( $this->dataLong, $newDecrypt );
+
+        // tear down
+        $view->unlink( $newFolder . '/' . $newFilename );
+        $view->unlink( $newFolder );
+    }
+
 // 	function testEncryption(){
 // 	
 // 		$key=uniqid();
diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php
index 3acc781a0966ea3a675c8dfc862218425d570eaa..d24dcaa0360d7c3644605c8efb7378e9830cfbae 100644
--- a/apps/files_encryption/tests/keymanager.php
+++ b/apps/files_encryption/tests/keymanager.php
@@ -26,6 +26,7 @@ class Test_Keymanager extends \PHPUnit_Framework_TestCase {
 	
 	function setUp() {
         // reset backend
+        \OC_User::clearBackends();
         \OC_User::useBackend('database');
 
 		\OC_FileProxy::$enabled = false;
@@ -41,18 +42,26 @@ class Test_Keymanager extends \PHPUnit_Framework_TestCase {
 		$keypair = Encryption\Crypt::createKeypair();
 		$this->genPublicKey =  $keypair['publicKey'];
 		$this->genPrivateKey = $keypair['privateKey'];
-		
-		$this->view = new \OC_FilesystemView( '/' );
-		
-		\OC_User::setUserId( 'admin' );
-		$this->userId = 'admin';
-		$this->pass = 'admin';
+
+        $this->view = new \OC_FilesystemView( '/' );
+
+        \OC_User::setUserId( 'admin' );
+        $this->userId = 'admin';
+        $this->pass = 'admin';
 
         $userHome = \OC_User::getHome($this->userId);
         $this->dataDir = str_replace('/'.$this->userId, '', $userHome);
 
-        \OC\Files\Filesystem::init( $this->userId, '/' );
-        \OC\Files\Filesystem::mount( 'OC_Filestorage_Local', array('datadir' => $this->dataDir), '/' );
+        // Filesystem related hooks
+        \OCA\Encryption\Helper::registerFilesystemHooks();
+
+        \OC_FileProxy::register(new OCA\Encryption\Proxy());
+
+        \OC_Util::tearDownFS();
+        \OC_User::setUserId('');
+        \OC\Files\Filesystem::setView(false);
+        \OC_Util::setupFS($this->userId);
+        \OC_User::setUserId($this->userId);
 
         $params['uid'] = $this->userId;
         $params['password'] = $this->pass;
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index b8433821d3bda8dd722c82e964e29cedc2686209..e2e26aa75b53499c50309403b79526f62073461c 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -462,6 +462,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
 
         \OC_Util::tearDownFS();
         \OC_User::setUserId('');
+        \OC\Files\Filesystem::setView(false);
         \OC_Util::setupFS($user);
         \OC_User::setUserId($user);
 
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index efd3f03bc6266e473428815ae2bfbb42fb7ff12d..2abf4096902810944d902f38718092d4f640af04 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -51,14 +51,22 @@ class Test_Enc_Util extends \PHPUnit_Framework_TestCase {
 		$this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles';
 		$this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
 		$this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
-		
-		$this->view = new \OC_FilesystemView( '/' );
+
+        $this->view = new \OC_FilesystemView( '/' );
 
         $userHome = \OC_User::getHome($this->userId);
         $this->dataDir = str_replace('/'.$this->userId, '', $userHome);
 
-        \OC\Files\Filesystem::init( $this->userId, '/' );
-        \OC\Files\Filesystem::mount( 'OC_Filestorage_Local', array('datadir' => $this->dataDir), '/' );
+        // Filesystem related hooks
+        \OCA\Encryption\Helper::registerFilesystemHooks();
+
+        \OC_FileProxy::register(new OCA\Encryption\Proxy());
+
+        \OC_Util::tearDownFS();
+        \OC_User::setUserId('');
+        \OC\Files\Filesystem::setView(false);
+        \OC_Util::setupFS($this->userId);
+        \OC_User::setUserId($this->userId);
 
         $params['uid'] = $this->userId;
         $params['password'] = $this->pass;
@@ -170,7 +178,7 @@ class Test_Enc_Util extends \PHPUnit_Framework_TestCase {
 
 		$util = new Encryption\Util( $this->view, $this->userId );
 		
-		$files = $util->findEncFiles( '/', 'encrypted' );
+		$files = $util->findEncFiles( '/'.$this->userId.'/');
 		
 		//var_dump( $files );