Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31460)
@@ -21,6 +21,7 @@
 
   /**
-   * Lock that locks next() and previous() methods. Used when downloading images
-   * to prevent concurrency problems.
+   * Lock that locks {@link MapillaryAbstractImage#next()} and
+   * {@link MapillaryAbstractImage#previous()} methods. Used when downloading
+   * images to prevent concurrency problems.
    */
   public static Lock LOCK = new ReentrantLock();
@@ -213,5 +214,6 @@
    * Returns the date the picture was taken in the given format.
    *
-   * @param format Format of the date. See {@link SimpleDateFormat}.
+   * @param format
+   *          Format of the date. See {@link SimpleDateFormat}.
    * @return A String containing the date the picture was taken using the given
    *         format.
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31460)
@@ -117,5 +117,5 @@
    * @return The image under the mouse cursor.
    */
-  public MapillaryAbstractImage getHighlighted() {
+  public MapillaryAbstractImage getHighlightedImage() {
     return this.highlightedImage;
   }
@@ -239,5 +239,5 @@
   public void selectPrevious(boolean moveToPicture) {
     if (getSelectedImage() == null)
-      return;
+      throw new IllegalStateException();
     if (getSelectedImage().getSequence() == null)
       throw new IllegalStateException();
@@ -277,5 +277,5 @@
     this.multiSelectedImages.clear();
     this.multiSelectedImages.add(image);
-    if (image != null) {
+    if (image != null && Main.main != null) {
       if (image instanceof MapillaryImage) {
         MapillaryImage mapillaryImage = (MapillaryImage) image;
@@ -284,16 +284,17 @@
           CacheUtils.downloadPicture((MapillaryImage) mapillaryImage.next());
           if (mapillaryImage.next().next() != null)
-            CacheUtils
-                .downloadPicture((MapillaryImage) mapillaryImage.next().next());
+            CacheUtils.downloadPicture((MapillaryImage) mapillaryImage.next()
+                .next());
         }
         if (mapillaryImage.previous() != null) {
-          CacheUtils.downloadPicture((MapillaryImage) mapillaryImage.previous());
+          CacheUtils
+              .downloadPicture((MapillaryImage) mapillaryImage.previous());
           if (mapillaryImage.previous().previous() != null)
-            CacheUtils.downloadPicture((MapillaryImage) mapillaryImage.previous()
-                .previous());
+            CacheUtils.downloadPicture((MapillaryImage) mapillaryImage
+                .previous().previous());
         }
       }
     }
-    if (zoom)
+    if (zoom && Main.main != null)
       Main.map.mapView.zoomTo(getSelectedImage().getLatLon());
     if (Main.main != null)
@@ -325,5 +326,6 @@
         this.setSelectedImage(image);
     }
-    Main.map.mapView.repaint();
+    if (Main.main != null)
+      Main.map.mapView.repaint();
   }
 
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31460)
@@ -415,5 +415,5 @@
     g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2),
         Main.map.mapView);
-    if (this.data.getHighlighted() == image) {
+    if (this.data.getHighlightedImage() == image) {
       drawPointHighlight(g, p, 16);
     }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java	(revision 31460)
@@ -139,21 +139,3 @@
     return this.images.get(i - 1);
   }
-
-  /**
-   * Returns the difference of index between two {@link MapillaryAbstractImage}
-   * objects belonging to the same {@link MapillarySequence}.
-   *
-   * @param image1
-   *          The first image.
-   * @param image2
-   *          The second image.
-   * @return The distance between two {@link MapillaryAbstractImage} objects
-   *         belonging to the same {@link MapillarySequence}.
-   */
-  public int getDistance(MapillaryAbstractImage image1,
-      MapillaryAbstractImage image2) {
-    if (!this.images.contains(image1) || !this.images.contains(image2))
-      throw new IllegalArgumentException();
-    return Math.abs(this.images.indexOf(image1) - this.images.indexOf(image2));
-  }
 }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java	(revision 31460)
@@ -22,7 +22,7 @@
  */
 public class WalkThread extends Thread implements MapillaryDataListener {
-  private int interval;
-  private MapillaryData data;
-  private Lock lock = new ReentrantLock();
+  private final int interval;
+  private final MapillaryData data;
+  private final Lock lock;
   private boolean end = false;
   private final boolean waitForFullQuality;
@@ -53,4 +53,5 @@
     this.data = MapillaryLayer.getInstance().getData();
     this.data.addListener(this);
+    this.lock = new ReentrantLock();
   }
 
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31460)
@@ -45,6 +45,5 @@
   public final static String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
   /** Executor that will run the petitions. */
-  private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5,
-      100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(50));
+  private static ThreadPoolExecutor EXECUTOR;
 
   /**
@@ -63,4 +62,6 @@
     queryStringParts.put("max_lat", maxLatLon.lat());
     queryStringParts.put("max_lon", maxLatLon.lon());
+    EXECUTOR = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS,
+        new ArrayBlockingQueue<Runnable>(50));
     run(new MapillarySquareDownloadManagerThread(queryStringParts));
   }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java	(revision 31460)
@@ -33,24 +33,24 @@
   protected JOptionPane optionPane;
   /** Button to export all downloaded images. */
-  public JRadioButton all;
+  public final JRadioButton all;
   /**
    * Button to export all images in the sequence of the selected MapillaryImage.
    */
-  public JRadioButton sequence;
+  public final JRadioButton sequence;
   /**
    * Button to export all images belonging to the selected
    * {@link MapillaryImage} objects.
    */
-  public JRadioButton selected;
+  public final JRadioButton selected;
   /** Button to rewrite all imported images. */
-  public JRadioButton rewrite;
+  public final JRadioButton rewrite;
   /** Group of button containing all the options. */
-  public ButtonGroup group;
-  private JButton choose;
-  private JLabel path;
+  public final ButtonGroup group;
+  private final JButton choose;
+  private final JLabel path;
   /** File chooser. */
   public JFileChooser chooser;
   protected String exportDirectory;
-  private JButton ok;
+  private final JButton ok;
 
   /**
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31460)
@@ -57,4 +57,5 @@
   private Rectangle selectedRect = null;
 
+  /** HyperlinkLabel shown in the bottom right corner. */
   protected HyperlinkLabel hyperlink;
 
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java	(revision 31460)
@@ -37,19 +37,19 @@
   @Override
   public void mousePressed(MouseEvent e) {
-    if (this.data.getHighlighted() == null)
+    if (this.data.getHighlightedImage() == null)
       return;
     if (this.lastClick == null
-        && this.data.getHighlighted() instanceof MapillaryImportedImage) {
-      this.lastClick = (MapillaryImportedImage) this.data.getHighlighted();
+        && this.data.getHighlightedImage() instanceof MapillaryImportedImage) {
+      this.lastClick = (MapillaryImportedImage) this.data.getHighlightedImage();
     } else if (this.lastClick != null
-        && this.data.getHighlighted() instanceof MapillaryImportedImage) {
-      if (((this.data.getHighlighted().previous() == null && this.lastClick.next() == null) || (this.data
-          .getHighlighted().next() == null && this.lastClick.previous() == null))
-          && (this.data.getHighlighted().getSequence() != this.lastClick.getSequence() || this.lastClick
+        && this.data.getHighlightedImage() instanceof MapillaryImportedImage) {
+      if (((this.data.getHighlightedImage().previous() == null && this.lastClick.next() == null) || (this.data
+          .getHighlightedImage().next() == null && this.lastClick.previous() == null))
+          && (this.data.getHighlightedImage().getSequence() != this.lastClick.getSequence() || this.lastClick
               .getSequence() == null)) {
-        join(this.lastClick, (MapillaryImportedImage) this.data.getHighlighted());
-      } else if (this.lastClick.next() == this.data.getHighlighted()
-          || this.lastClick.previous() == this.data.getHighlighted())
-        unjoin(this.lastClick, (MapillaryImportedImage) this.data.getHighlighted());
+        join(this.lastClick, (MapillaryImportedImage) this.data.getHighlightedImage());
+      } else if (this.lastClick.next() == this.data.getHighlightedImage()
+          || this.lastClick.previous() == this.data.getHighlightedImage())
+        unjoin(this.lastClick, (MapillaryImportedImage) this.data.getHighlightedImage());
       this.lastClick = null;
     }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java	(revision 31460)
@@ -182,9 +182,9 @@
     }
 
-    if (this.data.getHighlighted() != closestTemp && closestTemp != null) {
+    if (this.data.getHighlightedImage() != closestTemp && closestTemp != null) {
       this.data.setHighlightedImage(closestTemp);
       MapillaryMainDialog.getInstance().setImage(closestTemp);
       MapillaryMainDialog.getInstance().updateImage(false);
-    } else if (this.data.getHighlighted() != closestTemp && closestTemp == null) {
+    } else if (this.data.getHighlightedImage() != closestTemp && closestTemp == null) {
       this.data.setHighlightedImage(null);
       MapillaryMainDialog.getInstance().setImage(this.data.getSelectedImage());
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/AbstractTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/AbstractTest.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/AbstractTest.java	(revision 31460)
@@ -12,6 +12,4 @@
 public abstract class AbstractTest {
 
-  private static boolean started = false;
-
   /**
    * Initiates the basic parts of JOSM.
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java	(revision 31460)
@@ -10,9 +10,6 @@
 import javax.imageio.IIOException;
 
-import org.apache.commons.imaging.common.RationalNumber;
-import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction;
-import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
 
 /**
@@ -51,22 +48,3 @@
     img.getImage();
   }
-
-  /**
-   * Test degMinSecToDouble method.
-   */
-  @Test
-  public void degMinSecToDoubleTest() {
-    RationalNumber[] num = new RationalNumber[3];
-    num[0] = new RationalNumber(1, 1);
-    num[1] = new RationalNumber(0, 1);
-    num[2] = new RationalNumber(0, 1);
-    String ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH;
-    assertEquals(1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
-    ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH;
-    assertEquals(-1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
-    num[0] = new RationalNumber(180, 1);
-    assertEquals(-180, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
-    num[0] = new RationalNumber(190, 1);
-    assertEquals(170, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
-  }
 }
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImageTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImageTest.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImageTest.java	(revision 31460)
@@ -42,5 +42,5 @@
   }
 
-  private void testGetDate(String expected, MapillaryAbstractImage img,
+  private static void testGetDate(String expected, MapillaryAbstractImage img,
       boolean isoDates, boolean displayHour, boolean format24) {
     Main.pref.put("iso.dates", isoDates);
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryDataTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryDataTest.java	(revision 31460)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryDataTest.java	(revision 31460)
@@ -0,0 +1,157 @@
+package org.openstreetmap.josm.plugins.mapillary;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for {@link MapillaryData} class.
+ *
+ * @author nokutu
+ * @see MapillaryData
+ */
+public class MapillaryDataTest extends AbstractTest {
+
+  MapillaryData data;
+  MapillaryImage img1;
+  MapillaryImage img2;
+  MapillaryImage img3;
+  MapillaryImage img4;
+  MapillarySequence seq;
+
+  /**
+   * Creates a sample {@link MapillaryData} objects, 4 {@link MapillaryImage}
+   * objects and a {@link MapillarySequence} object.
+   */
+  @Before
+  public void setUp() {
+    this.img1 = new MapillaryImage("key1", 0.1, 0.1, 90);
+    this.img2 = new MapillaryImage("key2", 0.2, 0.2, 90);
+    this.img3 = new MapillaryImage("key3", 0.3, 0.3, 90);
+    this.img4 = new MapillaryImage("key4", 0.4, 0.4, 90);
+    this.seq = new MapillarySequence();
+
+    this.seq.add(Arrays.asList(new MapillaryAbstractImage[] { this.img1,
+        this.img2, this.img3, this.img4 }));
+    this.img1.setSequence(this.seq);
+    this.img2.setSequence(this.seq);
+    this.img3.setSequence(this.seq);
+    this.img4.setSequence(this.seq);
+
+    this.data = new MapillaryData();
+    this.data.add(this.seq.getImages());
+  }
+
+  /**
+   * Tests the addition of new images. If a second image with the same key as
+   * another one in the database, the one that is being added should be ignored.
+   */
+  @Test
+  public void addTest() {
+    this.data = new MapillaryData();
+    assertEquals(0, this.data.getImages().size());
+    this.data.add(this.img1);
+    assertEquals(1, this.data.getImages().size());
+    this.data.add(this.img1);
+    assertEquals(1, this.data.getImages().size());
+    this.data.add(Arrays.asList(new MapillaryAbstractImage[] { this.img2,
+        this.img3 }));
+    assertEquals(3, this.data.getImages().size());
+    this.data.add(Arrays.asList(new MapillaryAbstractImage[] { this.img3,
+        this.img4 }));
+    assertEquals(4, this.data.getImages().size());
+  }
+
+  /**
+   * Test that the size is properly calculated.
+   */
+  @Test
+  public void sizeTest() {
+    assertEquals(4, this.data.size());
+    this.data.add(new MapillaryImage("key5", 0.1, 0.1, 90));
+    assertEquals(5, this.data.size());
+  }
+
+  /**
+   * Test the {@link MapillaryData#setHighlightedImage(MapillaryAbstractImage)}
+   * and {@link MapillaryData#getHighlightedImage()} methods.
+   */
+  @Test
+  public void highlighTest() {
+    this.data.setHighlightedImage(this.img1);
+    assertEquals(this.img1, this.data.getHighlightedImage());
+
+    this.data.setHighlightedImage(null);
+    assertEquals(null, this.data.getHighlightedImage());
+  }
+
+  /**
+   * Tests the selection of images.
+   */
+  @Test
+  public void selectTest() {
+    this.data.setSelectedImage(this.img1);
+    assertEquals(this.img1, this.data.getSelectedImage());
+
+    this.data.setSelectedImage(this.img4);
+    assertEquals(this.img4, this.data.getSelectedImage());
+
+    this.data.setSelectedImage(null);
+    assertEquals(null, this.data.getSelectedImage());
+  }
+
+  /**
+   * Tests the {@link MapillaryData#selectNext()} and
+   * {@link MapillaryData#selectPrevious()} methods.
+   */
+  @Test
+  public void NextAndPreviousTest() {
+    this.data.setSelectedImage(this.img1);
+
+    this.data.selectNext();
+    assertEquals(this.img2, this.data.getSelectedImage());
+    this.data.selectNext();
+    assertEquals(this.img3, this.data.getSelectedImage());
+    this.data.selectPrevious();
+    assertEquals(this.img2, this.data.getSelectedImage());
+
+    this.data.setSelectedImage(null);
+    // Test IllegalStateException thrown by selectNext() when the selectedImage
+    // is null.
+    try {
+      this.data.selectNext();
+      fail();
+    } catch (IllegalStateException e) {
+    } catch (Exception e) {
+      fail();
+    }
+    // Test IllegalStateException thrown by selectPrevious() when the
+    // selectedImage is null.
+    try {
+      this.data.selectPrevious();
+      fail();
+    } catch (IllegalStateException e) {
+    } catch (Exception e) {
+      fail();
+    }
+  }
+
+  /**
+   * Test the multiselection of images. When a new image is selected, the
+   * multiselected List should reset.
+   */
+  @Test
+  public void multiSelectTest() {
+    assertEquals(0, this.data.getMultiSelectedImages().size());
+    this.data.setSelectedImage(this.img1);
+    assertEquals(1, this.data.getMultiSelectedImages().size());
+    this.data.addMultiSelectedImage(this.img2);
+    assertEquals(2, this.data.getMultiSelectedImages().size());
+    this.data.setSelectedImage(this.img1);
+    assertEquals(1, this.data.getMultiSelectedImages().size());
+  }
+}
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceTest.java	(revision 31460)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceTest.java	(revision 31460)
@@ -0,0 +1,81 @@
+package org.openstreetmap.josm.plugins.mapillary;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for the {@link MapillarySequence} class.
+ *
+ * @author nokutu
+ * @see MapillarySequence
+ */
+public class MapillarySequenceTest {
+
+  MapillaryImage img1;
+  MapillaryImage img2;
+  MapillaryImage img3;
+  MapillaryImage img4;
+  MapillarySequence seq;
+
+  /**
+   * Creates 4 {@link MapillaryImage} objects and puts them in a
+   * {@link MapillarySequence} object.
+   */
+  @Before
+  public void setUp() {
+    this.img1 = new MapillaryImage("key1", 0.1, 0.1, 90);
+    this.img2 = new MapillaryImage("key2", 0.2, 0.2, 90);
+    this.img3 = new MapillaryImage("key3", 0.3, 0.3, 90);
+    this.img4 = new MapillaryImage("key4", 0.4, 0.4, 90);
+    this.seq = new MapillarySequence();
+
+    this.seq.add(Arrays.asList(new MapillaryAbstractImage[] { this.img1,
+        this.img2, this.img3, this.img4 }));
+    this.img1.setSequence(this.seq);
+    this.img2.setSequence(this.seq);
+    this.img3.setSequence(this.seq);
+    this.img4.setSequence(this.seq);
+  }
+
+  /**
+   * Tests the {@link MapillarySequence#next(MapillaryAbstractImage)} and
+   * {@link MapillarySequence#previous(MapillaryAbstractImage)}.
+   */
+  @Test
+  public void nextAndPreviousTest() {
+    assertEquals(this.img2, this.img1.next());
+    assertEquals(this.img2, this.seq.next(this.img1));
+
+    assertEquals(this.img1, this.img2.previous());
+    assertEquals(this.img1, this.seq.previous(this.img2));
+
+    assertEquals(null, this.img4.next());
+    assertEquals(null, this.seq.next(this.img4));
+    assertEquals(null, this.img1.previous());
+    assertEquals(null, this.seq.previous(this.img1));
+
+    // Test IllegalArgumentException when asking for the next image of an image
+    // that is not in the sequence.
+    try {
+      this.seq.next(new MapillaryImage("key5", 0.5, 0.5, 90));
+      fail();
+    } catch (IllegalArgumentException e) {
+    } catch (Exception e) {
+      fail();
+    }
+    // Test IllegalArgumentException when asking for the previous image of an
+    // image that is not in the sequence.
+    try {
+      this.seq.previous(new MapillaryImage("key5", 0.5, 0.5, 90));
+      fail();
+    } catch (IllegalArgumentException e) {
+    } catch (Exception e) {
+      fail();
+    }
+  }
+}
Index: plications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/UploadTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/UploadTest.java	(revision 31459)
+++ 	(revision )
@@ -1,72 +1,0 @@
-package org.openstreetmap.josm.plugins.mapillary;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.ImageWriteException;
-import org.apache.commons.imaging.Imaging;
-import org.apache.commons.imaging.common.ImageMetadata;
-import org.apache.commons.imaging.common.RationalNumber;
-import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
-import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
-import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
-import org.junit.Test;
-import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction;
-import org.openstreetmap.josm.plugins.mapillary.oauth.UploadUtils;
-import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
-
-public class UploadTest extends AbstractTest {
-
-  /**
-   * Tests the updateFile method from {@link MapillaryImportAction} class.
-   */
-  @Test
-  public void updateFileTest() {
-    File image = new File("images/icon16.png");
-    MapillaryImportedImage img = new MapillaryImportAction().readNoTags(image,
-        new LatLon(0, 0));
-    File updatedFile = null;
-    try {
-      updatedFile = UploadUtils.updateFile(img);
-      ImageMetadata metadata = Imaging.getMetadata(updatedFile);
-      final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
-      assertTrue(jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF) != null);
-      assertTrue(jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE) != null);
-      assertTrue(jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF) != null);
-      assertTrue(jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE) != null);
-      assertTrue(jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION) != null);
-      assertTrue(jpegMetadata
-          .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL) != null);
-      assertEquals(0, MapillaryUtils.degMinSecToDouble(
-          (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch(
-              GpsTagConstants.GPS_TAG_GPS_LATITUDE).getValue(),
-          jpegMetadata
-              .findEXIFValueWithExactMatch(
-                  GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF).getValue()
-              .toString()), 0.01);
-      assertEquals(0, MapillaryUtils.degMinSecToDouble(
-          (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch(
-              GpsTagConstants.GPS_TAG_GPS_LONGITUDE).getValue(),
-          jpegMetadata
-              .findEXIFValueWithExactMatch(
-                  GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF).getValue()
-              .toString()), 0.01);
-
-    } catch (ImageReadException | ImageWriteException | IOException e) {
-      fail();
-    } finally {
-      updatedFile.delete();
-    }
-  }
-}
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/oauth/UploadTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/oauth/UploadTest.java	(revision 31460)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/oauth/UploadTest.java	(revision 31460)
@@ -0,0 +1,80 @@
+package org.openstreetmap.josm.plugins.mapillary.oauth;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.ImageMetadata;
+import org.apache.commons.imaging.common.RationalNumber;
+import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
+import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
+import org.junit.Test;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.plugins.mapillary.AbstractTest;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
+import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction;
+import org.openstreetmap.josm.plugins.mapillary.oauth.UploadUtils;
+import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
+
+/**
+ * Tests the {@link UploadUtils} class.
+ *
+ * @author nokutu
+ * @see UploadUtils
+ */
+public class UploadTest extends AbstractTest {
+
+  /**
+   * Tests the {@link UploadUtils#updateFile(MapillaryImportedImage)} method.
+   */
+  @Test
+  public void updateFileTest() {
+    File image = new File("images/icon16.png");
+    MapillaryImportedImage img = new MapillaryImportAction().readNoTags(image,
+        new LatLon(0, 0));
+    File updatedFile = null;
+    try {
+      updatedFile = UploadUtils.updateFile(img);
+      ImageMetadata metadata = Imaging.getMetadata(updatedFile);
+      final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
+      assertTrue(jpegMetadata
+          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF) != null);
+      assertTrue(jpegMetadata
+          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE) != null);
+      assertTrue(jpegMetadata
+          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF) != null);
+      assertTrue(jpegMetadata
+          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE) != null);
+      assertTrue(jpegMetadata
+          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION) != null);
+      assertTrue(jpegMetadata
+          .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL) != null);
+      assertEquals(0, MapillaryUtils.degMinSecToDouble(
+          (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch(
+              GpsTagConstants.GPS_TAG_GPS_LATITUDE).getValue(),
+          jpegMetadata
+              .findEXIFValueWithExactMatch(
+                  GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF).getValue()
+              .toString()), 0.01);
+      assertEquals(0, MapillaryUtils.degMinSecToDouble(
+          (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch(
+              GpsTagConstants.GPS_TAG_GPS_LONGITUDE).getValue(),
+          jpegMetadata
+              .findEXIFValueWithExactMatch(
+                  GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF).getValue()
+              .toString()), 0.01);
+
+    } catch (ImageReadException | ImageWriteException | IOException e) {
+      fail();
+    } finally {
+      updatedFile.delete();
+    }
+  }
+}
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java	(revision 31460)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java	(revision 31460)
@@ -0,0 +1,37 @@
+package org.openstreetmap.josm.plugins.mapillary.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.imaging.common.RationalNumber;
+import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
+import org.junit.Test;
+
+/**
+ * Tests the static methods of the class {@link MapillaryUtils}
+ *
+ * @see MapillaryUtils
+ * @author nokutu
+ *
+ */
+public class MapillaryUtilsTest {
+
+  /**
+   * Test {@link MapillaryUtils#degMinSecToDouble(RationalNumber[], String)}
+   * method.
+   */
+  @Test
+  public void degMinSecToDoubleTest() {
+    RationalNumber[] num = new RationalNumber[3];
+    num[0] = new RationalNumber(1, 1);
+    num[1] = new RationalNumber(0, 1);
+    num[2] = new RationalNumber(0, 1);
+    String ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH;
+    assertEquals(1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
+    ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH;
+    assertEquals(-1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
+    num[0] = new RationalNumber(180, 1);
+    assertEquals(-180, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
+    num[0] = new RationalNumber(190, 1);
+    assertEquals(170, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
+  }
+}
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/TestUtil.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/TestUtil.java	(revision 31459)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/TestUtil.java	(revision 31460)
@@ -1,12 +1,8 @@
 package org.openstreetmap.josm.plugins.mapillary.utils;
 
-import java.io.File;
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.projection.Projections;
-import org.openstreetmap.josm.plugins.PluginException;
-import org.openstreetmap.josm.plugins.PluginInformation;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
 import org.openstreetmap.josm.tools.I18n;
 
