diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js
index 11eb571727311875c75535fa2157c82c25679c7a..d4502c1254e6163d2d1922383064dcf8afd5a041 100644
--- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js
+++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js
@@ -42,15 +42,16 @@ define([ 'jquery', 'openbis' ], function($, openbis) {
 			return object;
 		};
 
-		this.createFacade = function(action) {
-			var facade = new openbis(testApiUrl);
-			action(facade);
+		this.createFacade = function() {
+			var dfd = $.Deferred();
+			dfd.resolve(new openbis(testApiUrl));
+			return dfd.promise();
 		};
 
 		this.createFacadeAndLogin = function() {
 			var dfd = $.Deferred();
 
-			this.createFacade(function(facade) {
+			this.createFacade().then(function(facade) {
 				facade.login(testUserId, testUserPassword).done(function() {
 					dfd.resolve(facade);
 				}).fail(function() {
@@ -217,11 +218,19 @@ define([ 'jquery', 'openbis' ], function($, openbis) {
 		};
 
 		this.assertNull = function(actual, msg) {
-			this.assert.equal(actual, null, msg);
+			this.assertEqual(actual, null, msg)
 		};
 
 		this.assertNotNull = function(actual, msg) {
-			this.assert.notEqual(actual, null, msg);
+			this.assertNotEqual(actual, null, msg);
+		};
+
+		this.assertTrue = function(actual, msg) {
+			this.assertEqual(actual, true, msg);
+		};
+
+		this.assertFalse = function(actual, msg) {
+			this.assertEqual(actual, false, msg);
 		};
 
 		this.assertEqual = function(actual, expected, msg) {
diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/login.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/login.js
new file mode 100644
index 0000000000000000000000000000000000000000..03a0e9d22666246191fcdff98eff0082bad50360
--- /dev/null
+++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/login.js
@@ -0,0 +1,27 @@
+define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, openbis, common) {
+	return function() {
+		QUnit.module("Login tests");
+
+		QUnit.test("loginAs()", function(assert) {
+			var c = new common(assert);
+			var done = assert.async();
+
+			$.when(c.createFacade(), c.createSpaceSearchCriterion(), c.createSpaceFetchOptions()).then(function(facade, criterion, fetchOptions) {
+				return facade.login("openbis_test_js", "password").then(function() {
+					return facade.searchSpaces(criterion, fetchOptions).then(function(spacesForInstanceAdmin) {
+						return facade.loginAs("openbis_test_js", "password", "test_space_admin").then(function() {
+							return facade.searchSpaces(criterion, fetchOptions).then(function(spacesForSpaceAdmin) {
+								c.assertTrue(spacesForInstanceAdmin.length > spacesForSpaceAdmin.length);
+								c.assertObjectsWithValues(spacesForSpaceAdmin, "code", [ "TEST" ]);
+								done();
+							});
+						});
+					});
+				});
+			}).fail(function(error) {
+				c.fail(error.message);
+				done();
+			});
+		});
+	}
+});
diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/main.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/main.js
index d32eca6dc95ea81208b46d0249305f109521152f..891fa56676fe2cc30a8c7311985ae25bc3799c8a 100644
--- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/main.js
+++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/main.js
@@ -1,4 +1,4 @@
-define([ 'test/space', 'test/project', 'test/experiment', 'test/sample', 'test/dataset', 'test/material', 'test/deletion', 'test/dto' ], function() {
+define([ 'test/login', 'test/space', 'test/project', 'test/experiment', 'test/sample', 'test/dataset', 'test/material', 'test/deletion', 'test/dto' ], function() {
 	var testSuites = arguments;
 	return function() {
 		for (var i = 0; i < testSuites.length; i++) {
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js
index d61ca8d32e5709eb3659a9c5a87695ec12c84146..099afefc9491b77e8de2622e1488e3deec2523a2 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js
@@ -93,7 +93,7 @@ define([ 'jquery', 'util/Json' ], function($, stjsUtil) {
 
 		this.loginAs = function(user, password, asUserId) {
 			var thisFacade = this;
-			return thisFacade._private.loginCommon(user, thisFacade._private.ajaxRequest({
+			return thisFacade._private.loginCommon(asUserId, thisFacade._private.ajaxRequest({
 				url : openbisUrl,
 				data : {
 					"method" : "loginAs",