diff --git a/tests/test-distribution.cc b/tests/test-distribution.cc
index ea76fe81a4cc3aa6e168223a7b3f1525dc1fd65e..2fa907785c719d4c27dafa5ad88ba27512efa839 100644
--- a/tests/test-distribution.cc
+++ b/tests/test-distribution.cc
@@ -46,7 +46,7 @@ int main ()
 
   for (size_t i = 0; i < p.size (); i++)
     if (p[i] - (double)(weight[i] / (double)total_weight) > DBL_EPSILON
-        || p[i] - (double)(weight[i] / (double)total_weight) > DBL_EPSILON) {
+        || - p[i] + (double)(weight[i] / (double)total_weight) > DBL_EPSILON) {
       std::cout << "p[" << i << "] = " << p[i] << std::endl
         << "weight[" << i << "] = " << weight[i] << std::endl
         << "Total weight = " << total_weight << std::endl
diff --git a/tests/test-statistics.cc b/tests/test-statistics.cc
index 26b52e1c627bd070a304afd0c9bc62cb098921b1..786f839c926cee8fd4988ab9a97eed3ab3a21600 100644
--- a/tests/test-statistics.cc
+++ b/tests/test-statistics.cc
@@ -35,7 +35,7 @@ class TestBin : public Bin {
     {
       os << val << " has :";
       for (std::list <double>::const_iterator it = l.begin ();
-          it != l.end (); it++)
+          it != l.end (); ++it)
         os << "   " << *it << std::endl;
       return os << std::endl;
     }
@@ -64,16 +64,22 @@ int main ()
 
   TestStatistics t;
   double *check = new double [100];
+  int status = EXIT_SUCCESS;
   for (int i = 0; i < 100; i++) {
     check[i] = ((double)(rand())/(double)rand());
     t.add (i, check[i]);
   }
   for (int i = 0; i < 100; i++) {
     TestStatistics::const_iterator it = t.find (i);
-    if (it == t.end ())
-      return EXIT_FAILURE;
-    if (it->l.size () != 1 && check[i] != it->l.front())
-      return EXIT_FAILURE;
+    if (it == t.end ()) {
+      status = EXIT_FAILURE;
+      break;
+    }
+    if (it->l.size () != 1 && check[i] != it->l.front()) {
+      status = EXIT_FAILURE;
+      break;
+    }
   }
-  return EXIT_SUCCESS;
+  delete[] check;
+  return status;
 }