anchor.diff:        expect(manager.currentLocation, nav3);
         manager.removeFile(nav3.file);
         expect(manager.currentLocation, isNull);
  -
  -
  -      locationProvider.currentMockLocation = null;
  -      manager.gotoLocation(nav1);
  -      locationProvider.currentMockLocation = nav1;
  -      manager.gotoLocation(nav2);
  -      locationProvider.currentMockLocation = nav2;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  +    });
  +
  +    test('remove files after some history navigation', () {
  +      MockNavigationLocationProviderWithFiles locationProvider = new MockNavigationLocationProviderWithFiles();
  +      NavigationManager manager = new NavigationManager(locationProvider);
  +      MockFileSystem fs = new MockFileSystem();
  +
  +      Workspace workspace = new Workspace(new MapPreferencesStore());
  +      FileEntry fileEntry1 = fs.createFile('test1.txt', contents: 'foobar');
  +      FileEntry fileEntry2 = fs.createFile('test2.txt', contents: 'foobar');
  +      FileEntry fileEntry3 = fs.createFile('test3.txt', contents: 'foobar');
  +      FileEntry fileEntry4 = fs.createFile('test4.txt', contents: 'foobar');
  +
  +      NavigationLocation nav1 = _mockLocationWithFile(new File(workspace, fileEntry1));
  +      NavigationLocation nav2 = _mockLocationWithFile(new File(workspace, fileEntry2));
  +      NavigationLocation nav3 = _mockLocationWithFile(new File(workspace, fileEntry3));
  +      NavigationLocation nav4 = _mockLocationWithFile(new File(workspace, fileEntry4));
  +
  +      manager.gotoLocation(nav1);
  +      locationProvider.navigationLocation = nav1;
  +      manager.gotoLocation(nav2);
  +      locationProvider.navigationLocation = nav2;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
         manager.removeFile(nav4.file);
         expect(manager.currentLocation, nav3);
  -      locationProvider.currentMockLocation = nav3;
  +      locationProvider.navigationLocation = nav3;
         manager.goBack();
         manager.removeFile(nav2.file);
         expect(manager.currentLocation, nav1);
  -      locationProvider.currentMockLocation = nav1;
  +      locationProvider.navigationLocation = nav1;
         manager.goForward();
         manager.removeFile(nav3.file);
         expect(manager.currentLocation, nav1);
  -      locationProvider.currentMockLocation = nav1;
  +      locationProvider.navigationLocation = nav1;
         manager.removeFile(nav1.file);
         expect(manager.currentLocation, isNull);
  -
  -      locationProvider.currentMockLocation = null;
  -      manager.gotoLocation(nav1);
  -      locationProvider.currentMockLocation = nav1;
  -      manager.gotoLocation(nav2);
  -      locationProvider.currentMockLocation = nav2;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  +    });
  +
  +    test('remove files after navigation', () {
  +      MockNavigationLocationProviderWithFiles locationProvider = new MockNavigationLocationProviderWithFiles();
  +      NavigationManager manager = new NavigationManager(locationProvider);
  +      MockFileSystem fs = new MockFileSystem();
  +
  +      Workspace workspace = new Workspace(new MapPreferencesStore());
  +      FileEntry fileEntry1 = fs.createFile('test1.txt', contents: 'foobar');
  +      FileEntry fileEntry2 = fs.createFile('test2.txt', contents: 'foobar');
  +      FileEntry fileEntry3 = fs.createFile('test3.txt', contents: 'foobar');
  +      FileEntry fileEntry4 = fs.createFile('test4.txt', contents: 'foobar');
  +
  +      NavigationLocation nav1 = _mockLocationWithFile(new File(workspace, fileEntry1));
  +      NavigationLocation nav2 = _mockLocationWithFile(new File(workspace, fileEntry2));
  +      NavigationLocation nav3 = _mockLocationWithFile(new File(workspace, fileEntry3));
  +      NavigationLocation nav4 = _mockLocationWithFile(new File(workspace, fileEntry4));
  +      locationProvider.navigationLocation = null;
  +      manager.gotoLocation(nav1);
  +      locationProvider.navigationLocation = nav1;
  +      manager.gotoLocation(nav2);
  +      locationProvider.navigationLocation = nav2;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
         manager.goBack();
         expect(manager.backLocation.file, nav4.file);
         expect(manager.forwardLocation.file, nav4.file);
  -      manager.removeFile(nav3. file);
  +      manager.removeFile(nav3.file);
         expect(manager.currentLocation.file, nav4.file);
         expect(manager.backLocation.file, nav2.file);
  -
  -      locationProvider.currentMockLocation = null;
  -      manager.gotoLocation(nav1);
  -      locationProvider.currentMockLocation = nav1;
  -      manager.gotoLocation(nav2);
  -      locationProvider.currentMockLocation = nav2;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  -      manager.gotoLocation(nav3);
  -      locationProvider.currentMockLocation = nav3;
  -      manager.gotoLocation(nav4);
  -      locationProvider.currentMockLocation = nav4;
  +    });
  +
  +    test('remove file and check for duplication in history', () {
  +      MockNavigationLocationProviderWithFiles locationProvider = new MockNavigationLocationProviderWithFiles();
  +      NavigationManager manager = new NavigationManager(locationProvider);
  +      MockFileSystem fs = new MockFileSystem();
  +
  +      Workspace workspace = new Workspace(new MapPreferencesStore());
  +      FileEntry fileEntry1 = fs.createFile('test1.txt', contents: 'foobar');
  +      FileEntry fileEntry2 = fs.createFile('test2.txt', contents: 'foobar');
  +      FileEntry fileEntry3 = fs.createFile('test3.txt', contents: 'foobar');
  +      FileEntry fileEntry4 = fs.createFile('test4.txt', contents: 'foobar');
  +
  +      NavigationLocation nav1 = _mockLocationWithFile(new File(workspace, fileEntry1));
  +      NavigationLocation nav2 = _mockLocationWithFile(new File(workspace, fileEntry2));
  +      NavigationLocation nav3 = _mockLocationWithFile(new File(workspace, fileEntry3));
  +      NavigationLocation nav4 = _mockLocationWithFile(new File(workspace, fileEntry4));
  +
  +      locationProvider.navigationLocation = null;
  +      manager.gotoLocation(nav1);
  +      locationProvider.navigationLocation = nav1;
  +      manager.gotoLocation(nav2);
  +      locationProvider.navigationLocation = nav2;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
  +      manager.gotoLocation(nav3);
  +      locationProvider.navigationLocation = nav3;
  +      manager.gotoLocation(nav4);
  +      locationProvider.navigationLocation = nav4;
         manager.removeFile(nav1.file);
         expect(manager.currentLocation.file, nav4.file);
         manager.removeFile(nav2.file);
  
positive.code:       expect(manager.currentLocation, isNotNull);
        expect(manager.forwardLocation, isNotNull);
      });
  
      test('remove file', () {
        MockNavigationLocationProviderWithFiles locationProvider = new MockNavigationLocationProviderWithFiles();
        NavigationManager manager = new NavigationManager(locationProvider);
        MockFileSystem fs = new MockFileSystem();
  
        Workspace workspace = new Workspace(new MapPreferencesStore());
        FileEntry fileEntry1 = fs.createFile('test1.txt', contents: 'foobar');
        FileEntry fileEntry2 = fs.createFile('test2.txt', contents: 'foobar');
        FileEntry fileEntry3 = fs.createFile('test3.txt', contents: 'foobar');
        FileEntry fileEntry4 = fs.createFile('test4.txt', contents: 'foobar');
  
        NavigationLocation nav1 = _mockLocationWithFile(new File(workspace, fileEntry1));
        NavigationLocation nav2 = _mockLocationWithFile(new File(workspace, fileEntry2));
        NavigationLocation nav3 = _mockLocationWithFile(new File(workspace, fileEntry3));
        NavigationLocation nav4 = _mockLocationWithFile(new File(workspace, fileEntry4));
  
  
        expect(manager.backLocation, isNull);
        expect(manager.forwardLocation, isNull);
        manager.gotoLocation(nav1);
        locationProvider.currentMockLocation = nav1;
        manager.gotoLocation(nav2);
        locationProvider.currentMockLocation = nav2;
        manager.gotoLocation(nav3);
        locationProvider.currentMockLocation = nav3;
        manager.gotoLocation(nav4);
        locationProvider.currentMockLocation = nav4;
        expect(manager.forwardLocation, isNull);
        expect(manager.backLocation, isNotNull);
        manager.removeFile(nav4.file);
  
negative.code: NavigationLocation _mockLocationWithFile(File mockFile) {
    return new NavigationLocation(mockFile, new Span(navigationOffset++, 0));
  }
  
  class MockNavigationLocationProvider implements NavigationLocationProvider {
    bool first = true;
  