diff --git a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
index 62e0ba82dc8af14a9d44440630b64eb947c712df..2b946cb89029854a3f59b383d68e2b973dff75c9 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
@@ -732,18 +732,21 @@ namespace MDEvents
   @param maskingRegion : Implicit function defining mask region.
   */
   TMDE(
-  void MDEventWorkspace)::setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion)
+    void MDEventWorkspace)::setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion)
   {
-    std::vector<IMDBox<MDE,nd> *> toMaskBoxes;
-
-    //Apply new masks
-    this->data->getBoxes(toMaskBoxes, 10000, true, maskingRegion);
-    for(size_t i = 0; i < toMaskBoxes.size(); ++i)
+    if(maskingRegion != NULL)
     {
-      toMaskBoxes[i]->mask();
-    }
+      std::vector<IMDBox<MDE,nd> *> toMaskBoxes;
+
+      //Apply new masks
+      this->data->getBoxes(toMaskBoxes, 10000, true, maskingRegion);
+      for(size_t i = 0; i < toMaskBoxes.size(); ++i)
+      {
+        toMaskBoxes[i]->mask();
+      }
 
-    delete maskingRegion;
+      delete maskingRegion;
+    }
   }
 
   /**
diff --git a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
index 4f98b9d43ed2563fb05d5eaa7f387095810e21f8..f2faae968047537f5b2a3dc0d1adfe725e56eb7e 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
@@ -1168,14 +1168,23 @@ namespace MDEvents
   */
   void MDHistoWorkspace::setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion)
   {
-    UNUSED_ARG(maskingRegion);
-    throw std::runtime_error("MDHistoWorkspace::setMDMasking not implemented yet.");
+    if(maskingRegion != NULL)
+    {
+      for(size_t i = 0; i < this->getNPoints(); ++i)
+      {
+        m_masks[i] = maskingRegion->isPointContained(this->getCenter(i));
+      }
+      delete maskingRegion;
+    }
   }
 
   /// Clear any existing masking.
   void MDHistoWorkspace::clearMDMasking()
   {
-    throw std::runtime_error("MDHistoWorkspace::clearMDMasking not implemented yet.");
+    for(size_t i = 0; i < this->getNPoints(); ++i)
+    {
+      m_masks[i] = false;
+    }
   }
 
 
diff --git a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp
index 5df3dc67a373f193d3167b95438b60af4f80704c..33c286ce0b49a6987d128e7a9a7d72bfbc1d07b6 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspaceIterator.cpp
@@ -137,6 +137,7 @@ namespace MDEvents
     delete [] m_binWidth;
     delete [] m_index;
     delete [] m_indexMax;
+
     if (m_function) delete m_function;
   }
   
@@ -185,23 +186,27 @@ namespace MDEvents
         for (size_t d=0; d<m_nd; d++)
         {
           m_center[d] = m_origin[d] + (coord_t(m_index[d]) + 0.5f) * m_binWidth[d];
-//          std::cout << m_center[d] << ",";
+          //          std::cout << m_center[d] << ",";
         }
-//        std::cout<<std::endl;
+        //        std::cout<<std::endl;
         // Keep incrementing until you are in the implicit function
       } while (!m_function->isPointContained(m_center)
-               && m_pos < m_max);
+        && m_pos < m_max);
     }
     else
     {
       ++m_pos;
     }
     //Keep calling next if the current position is masked.
-    while(m_skippingPolicy->keepGoing() && this->next())
+    bool ret = m_pos < m_max;
+    while(m_skippingPolicy->keepGoing())
     {
+      ret = this->next();
+      if(!ret)
+        break;
     }
     // Go through every point;
-    return (m_pos < m_max);
+    return ret;
   }
 
   //----------------------------------------------------------------------------------------------
diff --git a/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h
index fd35752485ad7c91b1e5f996e548fb6e958b487b..381333e7d2b32a375f62c71ed0a059165eb2c2be 100644
--- a/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h
+++ b/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h
@@ -36,13 +36,11 @@ using namespace Mantid::Geometry;
 class MDEventWorkspaceTest :    public CxxTest::TestSuite
 {
 private:
-
-  /// Helper function to return the number of masked bins in a workspace.
-  size_t getNumberMasked(IMDWorkspace_sptr ws)
+    /// Helper function to return the number of masked bins in a workspace. TODO: move helper into test helpers
+  size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws)
   {
-    std::vector<IMDIterator*> its = ws->createIterators(1, NULL);
+    Mantid::API::IMDIterator* it = ws->createIterator(NULL);
     size_t numberMasked = 0;
-    IMDIterator* it = its[0];
     size_t counter = 0;
     for(;counter < it->getDataSize(); ++counter)
     {
@@ -53,9 +51,9 @@ private:
       it->next(1); //Doesn't perform skipping on masked, bins, but next() does.
     }
     return numberMasked;
+    delete it;
   }
 
-
 public:
   // This pair of boilerplate methods prevent the suite being created statically
   // This means the constructor isn't called when running other tests
@@ -424,7 +422,6 @@ public:
 
     ws->setMDMasking(function);
 
-    std::vector<IMDIterator*> its = ws->createIterators(1, NULL);
     size_t numberMasked = getNumberMasked(ws);
     TSM_ASSERT_EQUALS("Didn't perform the masking as expected", expectedNumberMasked, numberMasked);
   }
@@ -447,6 +444,12 @@ public:
     doTestMasking(function, 1000); //1000 out of 1000 bins masked
   }
 
+  void test_maskNULL()
+  {
+    //Should do nothing in terms of masking, but should not throw.
+    doTestMasking(NULL, 0); //0 out of 1000 bins masked
+  }
+
   void test_maskNothing()
   {
     std::vector<coord_t> min;
diff --git a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h
index a381de4cf35e263aab2bb9303743637d98846699..a47893151f7f40f633758be859297b1ced8b667f 100644
--- a/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h
+++ b/Code/Mantid/Framework/MDEvents/test/MDHistoWorkspaceTest.h
@@ -5,6 +5,7 @@
 #include "MantidAPI/IMDWorkspace.h"
 #include "MantidDataObjects/WorkspaceSingleValue.h"
 #include "MantidGeometry/MDGeometry/MDHistoDimension.h"
+#include "MantidGeometry/MDGeometry/MDBoxImplicitFunction.h"
 #include "MantidKernel/System.h"
 #include "MantidKernel/Timer.h"
 #include "MantidKernel/VMD.h"
@@ -26,6 +27,23 @@ using namespace Mantid;
 
 class MDHistoWorkspaceTest : public CxxTest::TestSuite
 {
+private:
+    /// Helper function to return the number of masked bins in a workspace. TODO: move helper into test helpers
+  size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws)
+  {
+    Mantid::API::IMDIterator* it = ws->createIterator(NULL);
+    size_t numberMasked = 0;
+    size_t counter = 0;
+    for(;counter < it->getDataSize(); ++counter)
+    {
+      if(it->getIsMasked())
+      {
+        ++numberMasked;
+      }
+      it->next(1);
+    }
+    return numberMasked;
+  }
 public:
   // This pair of boilerplate methods prevent the suite being created statically
   // This means the constructor isn't called when running other tests
@@ -813,16 +831,80 @@ public:
     TS_ASSERT_DELTA( a->getSignalAt(2), 6.78, 1e-5);
   }
 
-  void test_setMDMasking()
+
+  void doTestMasking(MDImplicitFunction* function, size_t expectedNumberMasked)
+  {
+    // 10x10x10 eventWorkspace
+    MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace(1, 3, 10, 10.0);
+
+    ws->setMDMasking(function);
+
+    size_t numberMasked = getNumberMasked(ws);
+    TSM_ASSERT_EQUALS("Didn't perform the masking as expected", expectedNumberMasked, numberMasked);
+  }
+
+  void test_maskNULL()
+  {
+    doTestMasking(NULL, 0); //1000 out of 1000 bins masked
+  }
+
+  void test_mask_everything()
   {
-    MDHistoWorkspace_sptr anyHistoWorkspace = MDEventsTestHelper::makeFakeMDHistoWorkspace(1, 2, 5, 10.0, 3.0);
-    TSM_ASSERT_THROWS("Characterisation test. Should throw as not implemented.", anyHistoWorkspace->setMDMasking(NULL), std::runtime_error);
+    std::vector<coord_t> min;
+    std::vector<coord_t> max;
+
+    //Make the box that covers half the bins in the workspace. 
+    min.push_back(0);
+    min.push_back(0);
+    min.push_back(0);
+    max.push_back(10);
+    max.push_back(10);
+    max.push_back(10);
+
+    //Create an function that encompases ALL of the total bins.
+    MDImplicitFunction* function = new MDBoxImplicitFunction(min, max);
+    doTestMasking(function, 1000); //1000 out of 1000 bins masked
   }
 
-  void test_clearMDMasking()
+  
+  void test_maskHalf()
   {
-    MDHistoWorkspace_sptr anyHistoWorkspace = MDEventsTestHelper::makeFakeMDHistoWorkspace(1, 2, 5, 10.0, 3.0);
-    TSM_ASSERT_THROWS("Characterisation test. Should throw as not implemented.", anyHistoWorkspace->clearMDMasking(), std::runtime_error);
+    std::vector<coord_t> min;
+    std::vector<coord_t> max;
+
+    //Make the box that covers half the bins in the workspace. 
+    min.push_back(0);
+    min.push_back(0);
+    min.push_back(0);
+    max.push_back(10);
+    max.push_back(10);
+    max.push_back(4.99);
+
+    //Create an function that encompases 1/2 of the total bins.
+    MDImplicitFunction* function = new MDBoxImplicitFunction(min, max);
+    doTestMasking(function, 500); //500 out of 1000 bins masked
+  }
+
+
+  void test_clearMasking()
+  {
+    //Create a function that masks everything.
+    std::vector<coord_t> min;
+    std::vector<coord_t> max;
+    min.push_back(0);
+    min.push_back(0);
+    min.push_back(0);
+    max.push_back(10);
+    max.push_back(10);
+    max.push_back(10);
+    MDImplicitFunction* function = new MDBoxImplicitFunction(min, max);
+
+    MDEventWorkspace3Lean::sptr ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1 /*event per box*/);
+    ws->setMDMasking(function);
+
+    TSM_ASSERT_EQUALS("Everything should be masked.", 1000, getNumberMasked(ws));
+    TS_ASSERT_THROWS_NOTHING(ws->clearMDMasking());
+    TSM_ASSERT_EQUALS("Nothing should be masked.", 0, getNumberMasked(ws));
   }