diff --git a/full/Changes b/full/Changes
index 02d7491..8fd48a9 100644
--- a/full/Changes
+++ b/full/Changes
@@ -21,6 +21,8 @@
    - Removed codes related to user registration & password management (margaretha)  
 22/01/2019
    - Added create, edit, retrieve user default setting controllers (margaretha)
+22/01/2019
+   - Updated default setting controllers & added tests (margaretha)
 
 # version 0.61.4
 14/11/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java b/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java
index 39ee4ce..181d934 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java
@@ -2,6 +2,7 @@
 
 import java.util.Map;
 
+import org.apache.http.HttpStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -18,29 +19,37 @@
     @Autowired
     private DefaultSettingDao settingDao;
 
-    public void handlePutRequest (String username,
-            Map<String, Object> form, String authenticatedUser)
+    private void verifiyUsername (String username, String authenticatedUser)
             throws KustvaktException {
         if (!username.equals(authenticatedUser)) {
             throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
                     "Username verification failed. Path parameter username "
-                            + "must be the same as the authenticated username.");
+                            + "must be the same as the authenticated username.",
+                    username);
         }
-        else if (form == null || form.isEmpty()) {
+    }
+
+    public int handlePutRequest (String username, Map<String, Object> map,
+            String authenticatedUser) throws KustvaktException {
+        verifiyUsername(username, authenticatedUser);
+
+        if (map == null || map.isEmpty()) {
             throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
                     "Entity body is empty. No settings are given.");
         }
 
         Userdata userdata = new UserSettings(username);
-        userdata.readQuietly(form, false);
+        userdata.readQuietly(map, false);
 
         DefaultSetting defaultSetting =
                 settingDao.retrieveDefautlSetting(username);
         if (defaultSetting == null) {
             createDefaultSetting(username, userdata);
+            return HttpStatus.SC_CREATED;
         }
         else {
             updateDefaultSetting(defaultSetting, userdata);
+            return HttpStatus.SC_OK;
         }
     }
 
@@ -61,8 +70,11 @@
         settingDao.updateDefaultSetting(setting);
     }
 
-    public String retrieveDefaultSettings (String username)
-            throws KustvaktException {
+    public String retrieveDefaultSettings (String username,
+            String authenticatedUser) throws KustvaktException {
+
+        verifiyUsername(username, authenticatedUser);
+
         DefaultSetting defaultSetting =
                 settingDao.retrieveDefautlSetting(username);
         return defaultSetting.getSettings();
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java
index 904fab4..638cd8a 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java
@@ -34,7 +34,7 @@
  *
  */
 @Controller
-@Path("{version}/user")
+@Path("{version}/{username: ~[a-zA-Z0-9_]+}")
 @ResourceFilters({ AuthenticationFilter.class, APIVersionFilter.class,
         PiwikFilter.class })
 public class UserController {
@@ -47,40 +47,41 @@
     private OAuth2ScopeService scopeService;
 
     @PUT
-    @Path("settings/{username}")
+    @Path("setting")
     @Consumes(MediaType.APPLICATION_JSON)
     @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
             BlockingFilter.class })
     public Response createDefaultSetting (@Context SecurityContext context,
-            @PathParam("username") String username,
-            Map<String, Object> form) {
+            @PathParam("username") String username, Map<String, Object> map) {
 
         TokenContext tokenContext = (TokenContext) context.getUserPrincipal();
         try {
             scopeService.verifyScope(tokenContext,
                     OAuth2Scope.CREATE_DEFAULT_SETTING);
-            settingService.handlePutRequest(username, form,
+            int statusCode = settingService.handlePutRequest(username, map,
                     tokenContext.getUsername());
+            return Response.status(statusCode).build();
         }
         catch (KustvaktException e) {
             throw kustvaktResponseHandler.throwit(e);
         }
-        return Response.ok().build();
+
     }
 
     @GET
-    @Path("settings")
+    @Path("setting")
     @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
             BlockingFilter.class })
     @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
-    public Response createDefaultSetting (@Context SecurityContext context) {
+    public Response retrieveDefaultSetting (@Context SecurityContext context,
+            @PathParam("username") String username) {
         TokenContext tokenContext = (TokenContext) context.getUserPrincipal();
 
         try {
             scopeService.verifyScope(tokenContext,
                     OAuth2Scope.CREATE_DEFAULT_SETTING);
-            String settings = settingService
-                    .retrieveDefaultSettings(tokenContext.getUsername());
+            String settings = settingService.retrieveDefaultSettings(username,
+                    tokenContext.getUsername());
             return Response.ok(settings).build();
         }
         catch (KustvaktException e) {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java
index da336a0..d074d02 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java
@@ -18,6 +18,7 @@
 import de.ids_mannheim.korap.config.Attributes;
 import de.ids_mannheim.korap.config.SpringJerseyTest;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
 import de.ids_mannheim.korap.utils.JsonUtils;
 
 /**
@@ -26,15 +27,16 @@
  */
 public class UserControllerTest extends SpringJerseyTest {
 
-    private String username = "UserControllerTest";
+    private String username = "~UserControllerTest";
+    private String username2 = "~UserControllerTest2";
 
-    private ClientResponse sendPutRequest (Map<String, Object> form)
-            throws KustvaktException {
-        ClientResponse response = resource().path(API_VERSION).path("user")
-                .path("settings").path(username)
+    private ClientResponse sendPutRequest (String username,
+            Map<String, Object> map) throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION)
+                .path(username).path("setting")
                 .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
                         .createBasicAuthorizationHeaderValue(username, "pass"))
-                .type(MediaType.APPLICATION_JSON).entity(form)
+                .type(MediaType.APPLICATION_JSON).entity(map)
                 .put(ClientResponse.class);
 
         return response;
@@ -45,52 +47,85 @@
         String json = "{\"foundry\":\"opennlp\",\"metadata\":\"author title "
                 + "textSigle availability\",\"resultPerPage\":25}";
 
-        ClientResponse response = resource().path(API_VERSION).path("user")
-                .path("settings").path(username)
+        ClientResponse response = resource().path(API_VERSION)
+                .path(username).path("setting")
                 .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
                         .createBasicAuthorizationHeaderValue(username, "pass"))
                 .type(MediaType.APPLICATION_JSON).entity(json)
                 .put(ClientResponse.class);
 
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
+        assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
 
-        testRetrieveSettings("opennlp", 25,
+        testRetrieveSettings(username, "opennlp", 25,
                 "author title textSigle availability");
     }
 
     @Test
-    public void testCreateSettingWithForm () throws KustvaktException {
-        Map<String, Object> form = new HashMap<>();
-        form.put("foundry", "opennlp");
-        form.put("resultPerPage", 25);
-        form.put("metadata", "author title textSigle availability");
+    public void testCreateSettingWithMap () throws KustvaktException {
+        Map<String, Object> map = new HashMap<>();
+        map.put("foundry", "opennlp");
+        map.put("resultPerPage", 25);
+        map.put("metadata", "author title textSigle availability");
 
-        ClientResponse response = sendPutRequest(form);
-        assertEquals(Status.OK.getStatusCode(), response.getStatus());
+        ClientResponse response = sendPutRequest(username2, map);
+        assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
 
-        testRetrieveSettings("opennlp", 25,
+        testRetrieveSettings(username2, "opennlp", 25,
                 "author title textSigle availability");
 
-        testUpdateSetting();
+        testUpdateSetting(username2);
     }
 
-    private void testUpdateSetting () throws KustvaktException {
-        Map<String, Object> form = new HashMap<>();
-        form.put("foundry", "malt");
-        form.put("resultPerPage", 15);
-        form.put("metadata", "author title");
+    @Test
+    public void testPutDifferentUsername () throws KustvaktException {
+        String json = "{\"foundry\":\"opennlp\",\"metadata\":\"author title "
+                + "textSigle availability\",\"resultPerPage\":25}";
 
-        ClientResponse response = sendPutRequest(form);
+        ClientResponse response = resource().path(API_VERSION)
+                .path(username).path("setting")
+                .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
+                        .createBasicAuthorizationHeaderValue(username2, "pass"))
+                .type(MediaType.APPLICATION_JSON).entity(json)
+                .put(ClientResponse.class);
+
+        assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+        assertEquals(StatusCodes.INVALID_ARGUMENT,
+                node.at("/errors/0/0").asInt());
+    }
+
+    @Test
+    public void testGetDifferentUsername () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION)
+                .path(username).path("setting")
+                .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
+                        .createBasicAuthorizationHeaderValue(username2, "pass"))
+                .get(ClientResponse.class);
+
+        assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+        assertEquals(StatusCodes.INVALID_ARGUMENT,
+                node.at("/errors/0/0").asInt());
+    }
+
+    private void testUpdateSetting (String username) throws KustvaktException {
+        Map<String, Object> map = new HashMap<>();
+        map.put("foundry", "malt");
+        map.put("resultPerPage", 15);
+        map.put("metadata", "author title");
+
+        ClientResponse response = sendPutRequest(username, map);
         assertEquals(Status.OK.getStatusCode(), response.getStatus());
 
-        testRetrieveSettings("malt", 15, "author title");
-
+        testRetrieveSettings(username, "malt", 15, "author title");
     }
 
-    private void testRetrieveSettings (String foundry, int numOfResult,
+    private void testRetrieveSettings (String username, String foundry, int numOfResult,
             String metadata) throws KustvaktException {
-        ClientResponse response = resource().path(API_VERSION).path("user")
-                .path("settings")
+        ClientResponse response = resource().path(API_VERSION)
+                .path(username).path("setting")
                 .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
                         .createBasicAuthorizationHeaderValue(username, "pass"))
                 .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
