Index: trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java	(revision 11267)
+++ trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java	(revision 11269)
@@ -2,6 +2,10 @@
 package org.openstreetmap.josm.data.osm;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import org.junit.Rule;
 import org.junit.Test;
+import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
 
@@ -31,3 +35,34 @@
             .verify();
     }
+
+    /**
+     * Test LatLon constructor which might result in invalid bbox
+     */
+    @Test
+    public void testLatLonConstructor() {
+        LatLon latLon1 = new LatLon(10, 20);
+        LatLon latLon2 = new LatLon(20, 10);
+        BBox b1 = new BBox(latLon1, latLon2);
+        BBox b2 = new BBox(latLon2, latLon1);
+        assertTrue(b1.bounds(latLon1));
+        assertTrue(b2.bounds(latLon1));
+        assertTrue(b1.bounds(latLon2));
+        assertTrue(b2.bounds(latLon2));
+        assertTrue(b2.bounds(b1));
+        assertTrue(b1.bounds(b2));
+
+        // invalid latlon values
+        LatLon invalid1 = new LatLon(-190, 340);
+        BBox b3 = new BBox(invalid1, latLon1);
+        BBox b4 = new BBox(latLon1, invalid1);
+        BBox b5 = new BBox(invalid1, invalid1);
+        // what should be the result?
+        assertTrue(b3.isValid());
+        assertTrue(b4.isValid());
+        assertTrue(b3.bounds(latLon1));
+        assertTrue(b4.bounds(latLon1));
+        assertTrue(b5.isValid());
+        assertFalse(b5.isInWorld());
+    }
+
 }
Index: trunk/test/unit/org/openstreetmap/josm/data/osm/NodeTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/osm/NodeTest.java	(revision 11267)
+++ trunk/test/unit/org/openstreetmap/josm/data/osm/NodeTest.java	(revision 11269)
@@ -2,7 +2,9 @@
 package org.openstreetmap.josm.data.osm;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Rule;
@@ -43,3 +45,38 @@
         assertFalse(n.isOutsideDownloadArea());
     }
+
+    /**
+     * Test BBox calculation with Node
+     */
+    @Test
+    public void testBBox() {
+        DataSet ds = new DataSet();
+        Node n1 = new Node(1);
+        Node n2 = new Node(2);
+        Node n3 = new Node(3);
+        Node n4 = new Node(4);
+        n1.setIncomplete(true);
+        n2.setCoor(new LatLon(10, 10));
+        n3.setCoor(new LatLon(20, 20));
+        n4.setCoor(new LatLon(90, 180));
+        ds.addPrimitive(n1);
+        ds.addPrimitive(n2);
+        ds.addPrimitive(n3);
+        ds.addPrimitive(n4);
+
+        assertFalse(n1.getBBox().isValid());
+        assertTrue(n2.getBBox().isValid());
+        assertTrue(n3.getBBox().isValid());
+        assertTrue(n4.getBBox().isValid());
+        BBox box1 = n1.getBBox();
+        box1.add(n2.getCoor());
+        assertTrue(box1.isValid());
+        BBox box2 = n2.getBBox();
+        box2.add(n1.getCoor());
+        assertTrue(box2.isValid());
+        assertEquals(box1, box2);
+        box1.add(n3.getCoor());
+        assertTrue(box1.isValid());
+        assertEquals(box1.getCenter(), new LatLon(15, 15));
+    }
 }
Index: trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java	(revision 11267)
+++ trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java	(revision 11269)
@@ -9,4 +9,5 @@
 import java.util.Iterator;
 import java.util.List;
+import java.util.Random;
 
 import org.fest.reflect.core.Reflection;
@@ -175,4 +176,79 @@
         }
         Assert.assertEquals(0, qbWays.size());
+
+    }
+
+    /**
+     *  Add more data so that quad buckets tree has a few leaves
+     */
+    @Test
+    public void testSplitsWithIncompleteData() {
+        DataSet ds = new DataSet();
+        long nodeId = 1;
+        long wayId = 1;
+        final int NUM_COMPLETE_WAYS = 300;
+        final int NUM_INCOMPLETE_WAYS = 10;
+        final int NUM_NODES_PER_WAY = 20;
+        final int NUM_INCOMPLETE_NODES = 10;
+
+        // force splits in quad buckets
+        Random random = new Random(31);
+        for (int i = 0; i < NUM_COMPLETE_WAYS; i++) {
+            Way w = new Way(wayId++);
+            List<Node> nodes = new ArrayList<>();
+            double center = random.nextDouble() * 10;
+            for (int j = 0; j < NUM_NODES_PER_WAY; j++) {
+                Node n = new Node(nodeId++);
+                double lat = random.nextDouble() * 0.001;
+                double lon = random.nextDouble() * 0.001;
+                n.setCoor(new LatLon(center + lat, center + lon));
+                nodes.add(n);
+                ds.addPrimitive(n);
+            }
+            w.setNodes(nodes);
+            ds.addPrimitive(w);
+        }
+        Assert.assertEquals(NUM_COMPLETE_WAYS, ds.getWays().size());
+        Assert.assertEquals(NUM_COMPLETE_WAYS * NUM_NODES_PER_WAY, ds.getNodes().size());
+
+        // add some incomplete nodes
+        List<Node> incompleteNodes = new ArrayList<>();
+        for (int i = 0; i < NUM_INCOMPLETE_NODES; i++) {
+            Node n = new Node(nodeId++);
+            incompleteNodes.add(n);
+            n.setIncomplete(true);
+            ds.addPrimitive(n);
+        }
+        Assert.assertEquals(NUM_COMPLETE_WAYS * NUM_NODES_PER_WAY + NUM_INCOMPLETE_NODES, ds.getNodes().size());
+        // add some incomplete ways
+        List<Way> incompleteWays = new ArrayList<>();
+        for (int i = 0; i < NUM_INCOMPLETE_WAYS; i++) {
+            Way w = new Way(wayId++);
+            incompleteWays.add(w);
+            w.setIncomplete(true);
+            ds.addPrimitive(w);
+        }
+        Assert.assertEquals(NUM_COMPLETE_WAYS + NUM_INCOMPLETE_WAYS, ds.getWays().size());
+
+        BBox planet = new BBox(-180, -90, 180, 90);
+        // incomplete ways should not be found with search
+        Assert.assertEquals(NUM_COMPLETE_WAYS, ds.searchWays(planet).size());
+        // incomplete ways are only retrieved via iterator or object reference
+        for (Way w : incompleteWays) {
+            Assert.assertTrue(ds.getWays().contains(w));
+        }
+
+        QuadBuckets<Way> qb = new QuadBuckets<>();
+        qb.addAll(ds.getWays());
+        int count = qb.size();
+        Assert.assertEquals(count, ds.getWays().size());
+        Iterator<Way> iter = qb.iterator();
+        while (iter.hasNext()) {
+            iter.next();
+            iter.remove();
+            count--;
+            Assert.assertEquals(count, qb.size());
+        }
+        Assert.assertEquals(0, qb.size());
     }
 }
Index: trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java	(revision 11267)
+++ trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java	(revision 11269)
@@ -76,4 +76,13 @@
         Assert.assertEquals(w1.getBBox(), r1.getBBox());
         Assert.assertEquals(w1.getBBox(), r2.getBBox());
+
+        // create incomplete node and add it to the relation, this must not change the bbox
+        BBox oldBBox = r2.getBBox();
+        Node n4 = new Node();
+        n4.setIncomplete(true);
+        ds.addPrimitive(n4);
+        r2.addMember(new RelationMember("", n4));
+
+        Assert.assertEquals(oldBBox, r2.getBBox());
     }
 
