Index: /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphLayoutTest.cs
===================================================================
--- /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphLayoutTest.cs	(revision 15217)
+++ /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphLayoutTest.cs	(revision 15218)
@@ -33,5 +33,5 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersLayoutFruchtermanReingoldTest() {
-      var graph = new Graph(5, new[] {
+      using (var graph = new Graph(5, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -40,45 +40,46 @@
         Tuple.Create(2, 4),
         Tuple.Create(3, 4),
-      });
-      Assert.AreEqual(5, graph.Vertices);
-      try {
-        using (var matrix = graph.LayoutWithFruchtermanReingold()) {
-          Assert.AreEqual(5, matrix.Rows);
-          Assert.AreEqual(2, matrix.Columns);
-        }
-      } catch { Assert.Fail("Layouting with fruchterman-reingold using default parameters failed."); }
+      })) {
+        Assert.AreEqual(5, graph.Vertices);
+        try {
+          using (var matrix = graph.LayoutWithFruchtermanReingold()) {
+            Assert.AreEqual(5, matrix.Rows);
+            Assert.AreEqual(2, matrix.Columns);
+          }
+        } catch { Assert.Fail("Layouting with fruchterman-reingold using default parameters failed."); }
 
-      try {
-        using (var matrix = new Matrix(1, 1)) {
-          graph.LayoutWithFruchtermanReingold(50, 2, matrix);
-        }
-        Assert.Fail("Layouting with fruchterman-reingold using too little pre-initialized coordinates failed.");
-      } catch (ArgumentException) { }
+        try {
+          using (var matrix = new Matrix(1, 1)) {
+            graph.LayoutWithFruchtermanReingold(50, 2, matrix);
+          }
+          Assert.Fail("Layouting with fruchterman-reingold using too little pre-initialized coordinates failed.");
+        } catch (ArgumentException) { }
 
-      try {
-        using (var matrix = new Matrix(7, 3)) {
-          graph.LayoutWithFruchtermanReingold(50, 2, matrix);
-          Assert.Fail("Layouting with fruchterman-reingold using too many pre-initialized coordinates failed.");
-        }
-      } catch (ArgumentException) { }
+        try {
+          using (var matrix = new Matrix(7, 3)) {
+            graph.LayoutWithFruchtermanReingold(50, 2, matrix);
+            Assert.Fail("Layouting with fruchterman-reingold using too many pre-initialized coordinates failed.");
+          }
+        } catch (ArgumentException) { }
 
-      try {
-        using (var matrix = new Matrix(5, 2)) {
-          matrix[0, 0] = matrix[0, 1] = 1;
-          matrix[1, 0] = matrix[1, 1] = 2;
-          matrix[2, 0] = matrix[2, 1] = 3;
-          matrix[3, 0] = matrix[3, 1] = 4;
-          matrix[4, 0] = matrix[4, 1] = 5;
-          graph.LayoutWithFruchtermanReingold(50, 2, matrix);
-          Assert.AreEqual(5, matrix.Rows);
-          Assert.AreEqual(2, matrix.Columns);
-          Assert.IsFalse(
-               matrix[0, 0].IsAlmost(1) && matrix[0, 1].IsAlmost(1)
-            && matrix[1, 0].IsAlmost(2) && matrix[1, 1].IsAlmost(2)
-            && matrix[2, 0].IsAlmost(2) && matrix[2, 1].IsAlmost(2)
-            && matrix[3, 0].IsAlmost(2) && matrix[3, 1].IsAlmost(2)
-            && matrix[4, 0].IsAlmost(2) && matrix[4, 1].IsAlmost(2));
-        }
-      } catch { Assert.Fail("Layouting with fruchterman-reingold using pre-initialized coordinates failed."); }
+        try {
+          using (var matrix = new Matrix(5, 2)) {
+            matrix[0, 0] = matrix[0, 1] = 1;
+            matrix[1, 0] = matrix[1, 1] = 2;
+            matrix[2, 0] = matrix[2, 1] = 3;
+            matrix[3, 0] = matrix[3, 1] = 4;
+            matrix[4, 0] = matrix[4, 1] = 5;
+            graph.LayoutWithFruchtermanReingold(50, 2, matrix);
+            Assert.AreEqual(5, matrix.Rows);
+            Assert.AreEqual(2, matrix.Columns);
+            Assert.IsFalse(
+                 matrix[0, 0].IsAlmost(1) && matrix[0, 1].IsAlmost(1)
+              && matrix[1, 0].IsAlmost(2) && matrix[1, 1].IsAlmost(2)
+              && matrix[2, 0].IsAlmost(2) && matrix[2, 1].IsAlmost(2)
+              && matrix[3, 0].IsAlmost(2) && matrix[3, 1].IsAlmost(2)
+              && matrix[4, 0].IsAlmost(2) && matrix[4, 1].IsAlmost(2));
+          }
+        } catch { Assert.Fail("Layouting with fruchterman-reingold using pre-initialized coordinates failed."); }
+      }
     }
   }
Index: /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersGraphTest.cs
===================================================================
--- /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersGraphTest.cs	(revision 15217)
+++ /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersGraphTest.cs	(revision 15218)
@@ -36,5 +36,5 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersGraphConstructionAndFinalizationTest() {
-      var graph = new Graph(5, new[] {
+      using (var graph = new Graph(5, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -43,15 +43,17 @@
         Tuple.Create(2, 4),
         Tuple.Create(3, 4),
-      });
-      Assert.AreEqual(5, graph.Vertices);
-      Assert.IsFalse(graph.IsDirected);
+      })) {
+        Assert.AreEqual(5, graph.Vertices);
+        Assert.IsFalse(graph.IsDirected);
+      }
 
-      graph = new Graph(3, new[] {
+      using (var graph = new Graph(3, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
         Tuple.Create(1, 2),
-      }, directed: true);
-      Assert.AreEqual(3, graph.Vertices);
-      Assert.IsTrue(graph.IsDirected);
+      }, directed: true)) {
+        Assert.AreEqual(3, graph.Vertices);
+        Assert.IsTrue(graph.IsDirected);
+      }
     }
 
@@ -61,5 +63,5 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersGraphDensityTest() {
-      var graph = new Graph(5, new[] {
+      using (var graph = new Graph(5, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -68,13 +70,12 @@
         Tuple.Create(2, 4),
         Tuple.Create(3, 4),
-      });
+      })) {
 
-      var density = graph.Density();
-      // in un-directed graphs edges count twice
-      Assert.IsTrue(density.IsAlmost(12 / 20.0));
+        var density = graph.Density();
+        // in un-directed graphs edges count twice
+        Assert.IsTrue(density.IsAlmost(12 / 20.0));
+      }
 
-      graph.Dispose();
-
-      graph = new Graph(5, new[] {
+      using (var graph = new Graph(5, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -83,9 +84,10 @@
         Tuple.Create(2, 4),
         Tuple.Create(3, 4),
-      }, directed: true);
+      }, directed: true)) {
 
-      density = graph.Density();
-      // in directed graphs edges count twice
-      Assert.IsTrue(density.IsAlmost(6 / 20.0));
+        var density = graph.Density();
+        // in directed graphs edges count twice
+        Assert.IsTrue(density.IsAlmost(6 / 20.0));
+      }
     }
 
@@ -95,5 +97,5 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersGraphPageRankTest() {
-      var graph = new Graph(4, new[] {
+      using (var graph = new Graph(4, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -101,26 +103,26 @@
         Tuple.Create(2, 0),
         Tuple.Create(3, 2),
-      }, directed: true);
-      var ranks = graph.PageRank();
-      Assert.AreEqual(4, ranks.Length);
-      Assert.AreEqual(0.372, ranks[0], 0.01);
-      Assert.AreEqual(0.195, ranks[1], 0.01);
-      Assert.AreEqual(0.394, ranks[2], 0.01);
-      Assert.AreEqual(0.037, ranks[3], 0.01);
-
-      graph = new Graph(4, new[] {
+      }, directed: true)) {
+        var ranks = graph.PageRank();
+        Assert.AreEqual(4, ranks.Length);
+        Assert.AreEqual(0.372, ranks[0], 0.01);
+        Assert.AreEqual(0.195, ranks[1], 0.01);
+        Assert.AreEqual(0.394, ranks[2], 0.01);
+        Assert.AreEqual(0.037, ranks[3], 0.01);
+      }
+      using (var graph = new Graph(4, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(1, 2),
         Tuple.Create(2, 3),
         Tuple.Create(3, 0),
-      }, directed: true);
-      ranks = graph.PageRank();
-      Assert.AreEqual(4, ranks.Length);
-      Assert.AreEqual(0.250, ranks[0], 0.01);
-      Assert.AreEqual(0.250, ranks[1], 0.01);
-      Assert.AreEqual(0.250, ranks[2], 0.01);
-      Assert.AreEqual(0.250, ranks[3], 0.01);
-
-      graph = new Graph(4, new[] {
+      }, directed: true)) {
+        var ranks = graph.PageRank();
+        Assert.AreEqual(4, ranks.Length);
+        Assert.AreEqual(0.250, ranks[0], 0.01);
+        Assert.AreEqual(0.250, ranks[1], 0.01);
+        Assert.AreEqual(0.250, ranks[2], 0.01);
+        Assert.AreEqual(0.250, ranks[3], 0.01);
+      }
+      using (var graph = new Graph(4, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -129,11 +131,12 @@
         Tuple.Create(2, 0),
         Tuple.Create(3, 0),
-      }, directed: true);
-      ranks = graph.PageRank();
-      Assert.AreEqual(4, ranks.Length);
-      Assert.AreEqual(0.480, ranks[0], 0.01);
-      Assert.AreEqual(0.173, ranks[1], 0.01);
-      Assert.AreEqual(0.173, ranks[2], 0.01);
-      Assert.AreEqual(0.173, ranks[3], 0.01);
+      }, directed: true)) {
+        var ranks = graph.PageRank();
+        Assert.AreEqual(4, ranks.Length);
+        Assert.AreEqual(0.480, ranks[0], 0.01);
+        Assert.AreEqual(0.173, ranks[1], 0.01);
+        Assert.AreEqual(0.173, ranks[2], 0.01);
+        Assert.AreEqual(0.173, ranks[3], 0.01);
+      }
     }
 
@@ -143,5 +146,5 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersGraphBreadthFirstWalkTest() {
-      var graph = new Graph(4, new[] {
+      using (var graph = new Graph(4, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -149,16 +152,17 @@
         Tuple.Create(2, 0),
         Tuple.Create(3, 2),
-      }, directed: true);
-      var visited = new HashSet<int>();
-      BreadthFirstHandler handler = (graph1, currentVertexId, previousVertexId, nextVertexId, rank, distance, tag) => {
-        visited.Add(currentVertexId);
-        return false;
-      };
-      graph.BreadthFirstWalk(handler, 0, DirectedWalkMode.All, true, null);
-      Assert.AreEqual(4, visited.Count);
-      Assert.IsTrue(visited.Contains(0));
-      Assert.IsTrue(visited.Contains(1));
-      Assert.IsTrue(visited.Contains(2));
-      Assert.IsTrue(visited.Contains(3));
+      }, directed: true)) {
+        var visited = new HashSet<int>();
+        BreadthFirstHandler handler = (graph1, currentVertexId, previousVertexId, nextVertexId, rank, distance, tag) => {
+          visited.Add(currentVertexId);
+          return false;
+        };
+        graph.BreadthFirstWalk(handler, 0, DirectedWalkMode.All, true, null);
+        Assert.AreEqual(4, visited.Count);
+        Assert.IsTrue(visited.Contains(0));
+        Assert.IsTrue(visited.Contains(1));
+        Assert.IsTrue(visited.Contains(2));
+        Assert.IsTrue(visited.Contains(3));
+      }
     }
 
@@ -168,5 +172,5 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersGraphDepthFirstWalkTest() {
-      var graph = new Graph(4, new[] {
+      using (var graph = new Graph(4, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
@@ -174,16 +178,17 @@
         Tuple.Create(2, 0),
         Tuple.Create(3, 2),
-      }, directed: true);
-      var visited = new HashSet<int>();
-      DepthFirstHandler handler = (graph1, vertexId, distance, tag) => {
-        visited.Add(vertexId);
-        return false;
-      };
-      graph.DepthFirstWalk(handler, handler, 0, DirectedWalkMode.All, true, null);
-      Assert.AreEqual(4, visited.Count);
-      Assert.IsTrue(visited.Contains(0));
-      Assert.IsTrue(visited.Contains(1));
-      Assert.IsTrue(visited.Contains(2));
-      Assert.IsTrue(visited.Contains(3));
+      }, directed: true)) {
+        var visited = new HashSet<int>();
+        DepthFirstHandler handler = (graph1, vertexId, distance, tag) => {
+          visited.Add(vertexId);
+          return false;
+        };
+        graph.DepthFirstWalk(handler, handler, 0, DirectedWalkMode.All, true, null);
+        Assert.AreEqual(4, visited.Count);
+        Assert.IsTrue(visited.Contains(0));
+        Assert.IsTrue(visited.Contains(1));
+        Assert.IsTrue(visited.Contains(2));
+        Assert.IsTrue(visited.Contains(3));
+      }
     }
   }
Index: /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersMatrixTest.cs
===================================================================
--- /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersMatrixTest.cs	(revision 15217)
+++ /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersMatrixTest.cs	(revision 15218)
@@ -31,27 +31,28 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersMatrixConstructionAndFinalizationTest() {
-      var matrix = new Matrix(3, 2);
-      Assert.AreEqual(3, matrix.Rows);
-      Assert.AreEqual(2, matrix.Columns);
-      Assert.AreEqual(0, matrix[0, 0]);
-      matrix[0, 0] = 4;
-      var other = new Matrix(matrix);
-      Assert.AreEqual(3, other.Rows);
-      Assert.AreEqual(2, other.Columns);
-      Assert.AreEqual(4, other[0, 0]);
-
+      using (var matrix = new Matrix(3, 2)) {
+        Assert.AreEqual(3, matrix.Rows);
+        Assert.AreEqual(2, matrix.Columns);
+        Assert.AreEqual(0, matrix[0, 0]);
+        matrix[0, 0] = 4;
+        var other = new Matrix(matrix);
+        Assert.AreEqual(3, other.Rows);
+        Assert.AreEqual(2, other.Columns);
+        Assert.AreEqual(4, other[0, 0]);
+      }
       var mat = new double[,] {
         { 1, 2, 3 },
         { 4, 5, 6}
       };
-      matrix = new Matrix(mat);
-      Assert.AreEqual(2, matrix.Rows);
-      Assert.AreEqual(3, matrix.Columns);
-      var test = matrix.ToMatrix();
-      for (var i = 0; i < matrix.Rows; i++)
-        for (var j = 0; j < matrix.Columns; j++) {
-          Assert.AreEqual(mat[i, j], matrix[i, j]);
-          Assert.AreEqual(mat[i, j], test[i, j]);
-        }
+      using (var matrix = new Matrix(mat)) {
+        Assert.AreEqual(2, matrix.Rows);
+        Assert.AreEqual(3, matrix.Columns);
+        var test = matrix.ToMatrix();
+        for (var i = 0; i < matrix.Rows; i++)
+          for (var j = 0; j < matrix.Columns; j++) {
+            Assert.AreEqual(mat[i, j], matrix[i, j]);
+            Assert.AreEqual(mat[i, j], test[i, j]);
+          }
+      }
     }
 
@@ -61,23 +62,24 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersMatrixGetSetTest() {
-      var matrix = new Matrix(3, 2);
-      matrix[0, 0] = matrix[0, 1] = 4;
-      matrix[1, 0] = 3;
-      matrix[1, 1] = 2;
-      matrix[2, 0] = 1.5;
-      matrix[2, 1] = -0.5;
-      Assert.AreEqual(4, matrix[0, 0]);
-      Assert.AreEqual(4, matrix[0, 1]);
-      Assert.AreEqual(3, matrix[1, 0]);
-      Assert.AreEqual(2, matrix[1, 1]);
-      Assert.AreEqual(1.5, matrix[2, 0]);
-      Assert.AreEqual(-0.5, matrix[2, 1]);
+      using (var matrix = new Matrix(3, 2)) {
+        matrix[0, 0] = matrix[0, 1] = 4;
+        matrix[1, 0] = 3;
+        matrix[1, 1] = 2;
+        matrix[2, 0] = 1.5;
+        matrix[2, 1] = -0.5;
+        Assert.AreEqual(4, matrix[0, 0]);
+        Assert.AreEqual(4, matrix[0, 1]);
+        Assert.AreEqual(3, matrix[1, 0]);
+        Assert.AreEqual(2, matrix[1, 1]);
+        Assert.AreEqual(1.5, matrix[2, 0]);
+        Assert.AreEqual(-0.5, matrix[2, 1]);
 
-      var netmat = matrix.ToMatrix();
-      Assert.AreEqual(3, netmat.GetLength(0));
-      Assert.AreEqual(2, netmat.GetLength(1));
-      for (var i = 0; i < netmat.GetLength(0); i++)
-        for (var j = 0; j < netmat.GetLength(1); j++)
-          Assert.AreEqual(matrix[i, j], netmat[i, j]);
+        var netmat = matrix.ToMatrix();
+        Assert.AreEqual(3, netmat.GetLength(0));
+        Assert.AreEqual(2, netmat.GetLength(1));
+        for (var i = 0; i < netmat.GetLength(0); i++)
+          for (var j = 0; j < netmat.GetLength(1); j++)
+            Assert.AreEqual(matrix[i, j], netmat[i, j]);
+      }
     }
 
@@ -87,12 +89,13 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersMatrixFillTest() {
-      var matrix = new Matrix(3, 2);
-      matrix.Fill(2.6);
-      Assert.AreEqual(2.6, matrix[0, 0]);
-      Assert.AreEqual(2.6, matrix[0, 1]);
-      Assert.AreEqual(2.6, matrix[1, 0]);
-      Assert.AreEqual(2.6, matrix[1, 1]);
-      Assert.AreEqual(2.6, matrix[2, 0]);
-      Assert.AreEqual(2.6, matrix[2, 1]);
+      using (var matrix = new Matrix(3, 2)) {
+        matrix.Fill(2.6);
+        Assert.AreEqual(2.6, matrix[0, 0]);
+        Assert.AreEqual(2.6, matrix[0, 1]);
+        Assert.AreEqual(2.6, matrix[1, 0]);
+        Assert.AreEqual(2.6, matrix[1, 1]);
+        Assert.AreEqual(2.6, matrix[2, 0]);
+        Assert.AreEqual(2.6, matrix[2, 1]);
+      }
     }
 
@@ -102,8 +105,9 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersMatrixTransposeTest() {
-      var matrix = new Matrix(3, 2);
-      matrix.Transpose();
-      Assert.AreEqual(2, matrix.Rows);
-      Assert.AreEqual(3, matrix.Columns);
+      using (var matrix = new Matrix(3, 2)) {
+        matrix.Transpose();
+        Assert.AreEqual(2, matrix.Rows);
+        Assert.AreEqual(3, matrix.Columns);
+      }
     }
 
@@ -113,17 +117,18 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersMatrixScaleTest() {
-      var matrix = new Matrix(3, 2);
-      matrix[0, 0] = matrix[0, 1] = 4;
-      matrix[1, 0] = 3;
-      matrix[1, 1] = 2;
-      matrix[2, 0] = 1.5;
-      matrix[2, 1] = -0.5;
-      matrix.Scale(2);
-      Assert.AreEqual(8, matrix[0, 0]);
-      Assert.AreEqual(8, matrix[0, 1]);
-      Assert.AreEqual(6, matrix[1, 0]);
-      Assert.AreEqual(4, matrix[1, 1]);
-      Assert.AreEqual(3, matrix[2, 0]);
-      Assert.AreEqual(-1, matrix[2, 1]);
+      using (var matrix = new Matrix(3, 2)) {
+        matrix[0, 0] = matrix[0, 1] = 4;
+        matrix[1, 0] = 3;
+        matrix[1, 1] = 2;
+        matrix[2, 0] = 1.5;
+        matrix[2, 1] = -0.5;
+        matrix.Scale(2);
+        Assert.AreEqual(8, matrix[0, 0]);
+        Assert.AreEqual(8, matrix[0, 1]);
+        Assert.AreEqual(6, matrix[1, 0]);
+        Assert.AreEqual(4, matrix[1, 1]);
+        Assert.AreEqual(3, matrix[2, 0]);
+        Assert.AreEqual(-1, matrix[2, 1]);
+      }
     }
   }
Index: /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs
===================================================================
--- /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs	(revision 15217)
+++ /stable/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs	(revision 15218)
@@ -20,5 +20,8 @@
 #endregion
 
+using System;
+using System.Collections.Generic;
 using System.Linq;
+using HeuristicLab.Encodings.RealVectorEncoding;
 using HeuristicLab.IGraph.Wrappers;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -32,18 +35,20 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersVectorConstructionAndFinalizationTest() {
-      var vector = new Vector(7);
-      Assert.AreEqual(7, vector.Length);
-      Assert.AreEqual(0, vector[0]);
-      vector[0] = 4;
-      var other = new Vector(vector);
-      Assert.AreEqual(7, other.Length);
-      Assert.AreEqual(4, other[0]);
-
+      using (var vector = new Vector(7)) {
+        Assert.AreEqual(7, vector.Length);
+        Assert.AreEqual(0, vector[0]);
+        vector[0] = 4;
+        using (var other = new Vector(vector)) {
+          Assert.AreEqual(7, other.Length);
+          Assert.AreEqual(4, other[0]);
+        }
+      }
       var myvec = new double[] { 1, 2, 3 };
-      vector = new Vector(myvec);
-      Assert.AreEqual(3, vector.Length);
-      Assert.AreEqual(myvec[0], vector[0]);
-      Assert.AreEqual(myvec[1], vector[1]);
-      Assert.AreEqual(myvec[2], vector[2]);
+      using (var vector = new Vector(myvec)) {
+        Assert.AreEqual(3, vector.Length);
+        Assert.AreEqual(myvec[0], vector[0]);
+        Assert.AreEqual(myvec[1], vector[1]);
+        Assert.AreEqual(myvec[2], vector[2]);
+      }
     }
 
@@ -53,19 +58,20 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersVectorGetSetTest() {
-      var vector = new Vector(5);
-      vector[0] = vector[1] = 4;
-      vector[2] = 3;
-      vector[3] = 1.5;
-      vector[4] = -0.5;
-      Assert.AreEqual(4, vector[0]);
-      Assert.AreEqual(4, vector[1]);
-      Assert.AreEqual(3, vector[2]);
-      Assert.AreEqual(1.5, vector[3]);
-      Assert.AreEqual(-0.5, vector[4]);
+      using (var vector = new Vector(5)) {
+        vector[0] = vector[1] = 4;
+        vector[2] = 3;
+        vector[3] = 1.5;
+        vector[4] = -0.5;
+        Assert.AreEqual(4, vector[0]);
+        Assert.AreEqual(4, vector[1]);
+        Assert.AreEqual(3, vector[2]);
+        Assert.AreEqual(1.5, vector[3]);
+        Assert.AreEqual(-0.5, vector[4]);
 
-      var netmat = vector.ToArray();
-      Assert.AreEqual(5, netmat.Length);
-      for (var i = 0; i < netmat.Length; i++)
-        Assert.AreEqual(vector[i], netmat[i]);
+        var netmat = vector.ToArray();
+        Assert.AreEqual(5, netmat.Length);
+        for (var i = 0; i < netmat.Length; i++)
+          Assert.AreEqual(vector[i], netmat[i]);
+      }
     }
 
@@ -75,7 +81,8 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersVectorFillTest() {
-      var vector = new Vector(5);
-      vector.Fill(2.3);
-      Assert.IsTrue(new[] { 2.3, 2.3, 2.3, 2.3, 2.3 }.SequenceEqual(vector.ToArray()));
+      using (var vector = new Vector(5)) {
+        vector.Fill(2.3);
+        Assert.IsTrue(new[] { 2.3, 2.3, 2.3, 2.3, 2.3 }.SequenceEqual(vector.ToArray()));
+      }
     }
 
@@ -85,11 +92,12 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersVectorReverseTest() {
-      var vector = new Vector(5);
-      vector[0] = vector[1] = 4;
-      vector[2] = 3;
-      vector[3] = 1.5;
-      vector[4] = -0.5;
-      vector.Reverse();
-      Assert.IsTrue(new[] { -0.5, 1.5, 3, 4, 4 }.SequenceEqual(vector.ToArray()));
+      using (var vector = new Vector(5)) {
+        vector[0] = vector[1] = 4;
+        vector[2] = 3;
+        vector[3] = 1.5;
+        vector[4] = -0.5;
+        vector.Reverse();
+        Assert.IsTrue(new[] { -0.5, 1.5, 3, 4, 4 }.SequenceEqual(vector.ToArray()));
+      }
     }
 
@@ -99,12 +107,24 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersVectorShuffleTest() {
-      var vector = new Vector(5);
-      vector[0] = vector[1] = 4;
-      vector[2] = 3;
-      vector[3] = 1.5;
-      vector[4] = -0.5;
-      vector.Shuffle();
-      Assert.IsFalse(new[] { -0.5, 1.5, 3, 4, 4 }.SequenceEqual(vector.ToArray()));
-      Assert.IsFalse(new[] { 4, 4, 3, 1.5, -0.5 }.SequenceEqual(vector.ToArray()));
+      var different = new HashSet<RealVector>(new RealVectorEqualityComparer());
+      for (var i = 0; i < 100; i++) {
+        using (var vector = new Vector(5)) {
+          vector[0] = vector[1] = 4;
+          vector[2] = 3;
+          vector[3] = 1.5;
+          vector[4] = -0.5;
+          vector.Shuffle();
+          var result = vector.ToArray();
+          different.Add(new RealVector(result));
+          Assert.AreEqual(2, result.Count(x => x == 4));
+          Assert.AreEqual(1, result.Count(x => x == 3));
+          Assert.AreEqual(1, result.Count(x => x == 1.5));
+          Assert.AreEqual(1, result.Count(x => x == -0.5));
+        }
+      }
+      // There should be reasonable low probability that all 100 shuffles result in exactly the same vector
+      Assert.IsTrue(different.Count > 1);
+      Assert.IsTrue(different.Count <= 60); // there are a total of 60 different shuffles 5! / 2!
+      Console.WriteLine("Shuffle produced " + different.Count + " unique vectors");
     }
 
@@ -114,11 +134,12 @@
     [TestProperty("Time", "short")]
     public void IGraphWrappersVectorScaleTest() {
-      var vector = new Vector(5);
-      vector[0] = vector[1] = 4;
-      vector[2] = 3;
-      vector[3] = 1.5;
-      vector[4] = -0.5;
-      vector.Scale(2);
-      Assert.IsTrue(new double[] { 8, 8, 6, 3, -1 }.SequenceEqual(vector.ToArray()));
+      using (var vector = new Vector(5)) {
+        vector[0] = vector[1] = 4;
+        vector[2] = 3;
+        vector[3] = 1.5;
+        vector[4] = -0.5;
+        vector.Scale(2);
+        Assert.IsTrue(new double[] { 8, 8, 6, 3, -1 }.SequenceEqual(vector.ToArray()));
+      }
     }
   }
