Index: /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 9731)
+++ /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 9732)
@@ -273,5 +273,6 @@
                 //
                 final OsmDataLayer layer = createNewLayer(newLayerName);
-                Main.main.addLayer(layer, computeBbox(bounds));
+                if (Main.main != null)
+                    Main.main.addLayer(layer, computeBbox(bounds));
                 return layer;
             }
Index: /trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 9731)
+++ /trunk/src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 9732)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
@@ -122,4 +123,12 @@
             }
 
+            if ("file".equals(url.getProtocol())) {
+                try {
+                    return url.openStream();
+                } catch (IOException e) {
+                    throw new OsmTransferException(e);
+                }
+            }
+
             final HttpClient client = HttpClient.create(url);
             activeConnection = client;
Index: /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java	(revision 9731)
+++ /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java	(revision 9732)
@@ -115,6 +115,6 @@
     protected void validateRequest() throws RequestHandlerBadRequestException {
         try {
-            lat = Double.parseDouble(args.get("lat"));
-            lon = Double.parseDouble(args.get("lon"));
+            lat = Double.parseDouble(args != null ? args.get("lat") : "");
+            lon = Double.parseDouble(args != null ? args.get("lon") : "");
         } catch (NumberFormatException e) {
             throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+')', e);
Index: /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java	(revision 9731)
+++ /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java	(revision 9732)
@@ -98,5 +98,5 @@
     @Override
     protected void validateRequest() throws RequestHandlerBadRequestException {
-        String urlString = args.get("url");
+        String urlString = args != null ? args.get("url") : null;
         if (Main.pref.getBoolean("remotecontrol.importhandler.fix_url_query", true)) {
             urlString = Utils.fixURLQuery(urlString);
Index: /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java	(revision 9731)
+++ /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java	(revision 9732)
@@ -223,18 +223,24 @@
         List<String> missingKeys = new LinkedList<>();
         boolean error = false;
-        if (mandatory != null) for (String key : mandatory) {
-            String value = args.get(key);
-            if (value == null || value.isEmpty()) {
-                error = true;
-                Main.warn('\'' + myCommand + "' remote control request must have '" + key + "' parameter");
-                missingKeys.add(key);
+        if (mandatory != null && args != null) {
+            for (String key : mandatory) {
+                String value = args.get(key);
+                if (value == null || value.isEmpty()) {
+                    error = true;
+                    Main.warn('\'' + myCommand + "' remote control request must have '" + key + "' parameter");
+                    missingKeys.add(key);
+                }
             }
         }
         Set<String> knownParams = new HashSet<>();
-        if (mandatory != null) Collections.addAll(knownParams, mandatory);
-        if (optional != null) Collections.addAll(knownParams, optional);
-        for (String par: args.keySet()) {
-            if (!knownParams.contains(par)) {
-                Main.warn("Unknown remote control parameter {0}, skipping it", par);
+        if (mandatory != null)
+            Collections.addAll(knownParams, mandatory);
+        if (optional != null)
+            Collections.addAll(knownParams, optional);
+        if (args != null) {
+            for (String par: args.keySet()) {
+                if (!knownParams.contains(par)) {
+                    Main.warn("Unknown remote control parameter {0}, skipping it", par);
+                }
             }
         }
Index: /trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 9731)
+++ /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 9732)
@@ -1221,5 +1221,5 @@
      */
     public static String fixURLQuery(String url) {
-        if (url.indexOf('?') == -1)
+        if (url == null || url.indexOf('?') == -1)
             return url;
 
Index: /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java	(revision 9732)
+++ /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java	(revision 9732)
@@ -0,0 +1,104 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.io.remotecontrol.handler;
+
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
+
+/**
+ * Unit tests of {@link AddNodeHandler} class.
+ */
+public class AddNodeHandlerTest {
+
+    /**
+     * Rule used for tests throwing exceptions.
+     */
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init(true);
+    }
+
+    private static AddNodeHandler newHandler(String url) {
+        AddNodeHandler req = new AddNodeHandler();
+        if (url != null)
+            req.setUrl(url);
+        return req;
+    }
+
+    /**
+     * Unit test for bad request - no layer.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestNoLayer() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("There is no layer opened to add node");
+        newHandler("https://localhost?lat=0&lon=0").handle();
+    }
+
+    /**
+     * Unit test for bad request - no param.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestNoParam() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("NumberFormatException (empty String)");
+        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
+        try {
+            Main.main.addLayer(layer);
+            newHandler(null).handle();
+        } finally {
+            Main.main.removeLayer(layer);
+        }
+    }
+
+    /**
+     * Unit test for bad request - invalid URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestInvalidUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("The following keys are mandatory, but have not been provided: lat, lon");
+        newHandler("invalid_url").handle();
+    }
+
+    /**
+     * Unit test for bad request - incomplete URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestIncompleteUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("The following keys are mandatory, but have not been provided: lat, lon");
+        newHandler("https://localhost").handle();
+    }
+
+    /**
+     * Unit test for nominal request - local data file.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testNominalRequest() throws Exception {
+        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
+        try {
+            Main.main.addLayer(layer);
+            newHandler("https://localhost?lat=0&lon=0").handle();
+        } finally {
+            Main.main.removeLayer(layer);
+        }
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java	(revision 9731)
+++ /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java	(revision 9732)
@@ -4,5 +4,16 @@
 import static org.junit.Assert.assertEquals;
 
+import java.io.File;
+
+import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.TestUtils;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -12,11 +23,80 @@
 
     /**
+     * Rule used for tests throwing exceptions.
+     */
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    /**
+     * Setup test.
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init(true);
+    }
+
+    private static ImportHandler newHandler(String url) {
+        ImportHandler req = new ImportHandler();
+        if (url != null)
+            req.setUrl(url);
+        return req;
+    }
+
+    /**
      * Non-regression test for bug #7434.
      */
     @Test
     public void testTicket7434() {
-        final ImportHandler req = new ImportHandler();
-        req.setUrl("http://localhost:8111/import?url=http://localhost:8888/relations?relations=19711&mode=recursive");
+        ImportHandler req = newHandler("http://localhost:8111/import?url=http://localhost:8888/relations?relations=19711&mode=recursive");
         assertEquals("http://localhost:8888/relations?relations=19711&mode=recursive", req.args.get("url"));
     }
+
+    /**
+     * Unit test for bad request - no param.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestNoParam() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("MalformedURLException: null");
+        newHandler(null).handle();
+    }
+
+    /**
+     * Unit test for bad request - invalid URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestInvalidUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("MalformedURLException: no protocol: invalid_url");
+        newHandler("https://localhost?url=invalid_url").handle();
+    }
+
+    /**
+     * Unit test for bad request - incomplete URL.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testBadRequestIncompleteUrl() throws Exception {
+        thrown.expect(RequestHandlerBadRequestException.class);
+        thrown.expectMessage("The following keys are mandatory, but have not been provided: url");
+        newHandler("https://localhost").handle();
+    }
+
+    /**
+     * Unit test for nominal request - local data file.
+     * @throws Exception if any error occurs
+     */
+    @Test
+    public void testNominalRequest() throws Exception {
+        String url = new File(TestUtils.getRegressionDataFile(11957, "data.osm")).toURI().toURL().toExternalForm();
+        try {
+            newHandler("https://localhost?url=" + Utils.encodeUrl(url)).handle();
+        } finally {
+            for (OsmDataLayer layer : Main.map.mapView.getLayersOfType(OsmDataLayer.class)) {
+                Main.main.removeLayer(layer);
+            }
+        }
+    }
 }
