Index: Invariant/invariant.py
===================================================================
--- Invariant/invariant.py	(revision 2e94cbde806c33b8f8cb45a9a3538305cab0da4d)
+++ Invariant/invariant.py	(revision c75a8ed10188ecdc61e67bf33da877dab8980eb5)
@@ -16,5 +16,5 @@
     TODO: 
         - intro / documentation
-        - add unit tests for sufrace/volume computation with and without extrapolation.
+
 """
 import math 
@@ -575,5 +575,5 @@
         return self._get_qstar(data), self._get_qstar_uncertainty(data)
     
-    def get_extra_data_low(self, npts_in=None, q_start=None, nsteps=20):
+    def get_extra_data_low(self, npts_in=None, q_start=None, npts=20):
         """
             Returns the extrapolated data used for the loew-Q invariant calculation.
@@ -601,5 +601,5 @@
 
         return self._get_extrapolated_data(model=self._low_extrapolation_function,
-                                           npts=nsteps,
+                                           npts=npts,
                                            q_start=q_start, q_end=q_end)
           
@@ -620,6 +620,6 @@
         if npts_in is None:
             npts_in = self._high_extrapolation_npts
-        npts = len(self._data.x)
-        q_start = self._data.x[min(npts, npts-npts_in+1)]
+        _npts = len(self._data.x)
+        q_start = self._data.x[min(_npts, _npts-npts_in)]
         
         if q_start >= q_end:
@@ -835,5 +835,6 @@
         v, dv = self.get_volume_fraction_with_error(contrast, extrapolation)
 
-        s = self.get_surface(contrast=contrast, porod_const=porod_const)
+        s = self.get_surface(contrast=contrast, porod_const=porod_const, 
+                             extrapolation=extrapolation)
         ds = porod_const * 2 * math.pi * (( dv - 2 * v * dv)/ self._qstar\
                  + self._qstar_err * ( v - v**2))
Index: Invariant/test/utest_data_handling.py
===================================================================
--- Invariant/test/utest_data_handling.py	(revision bdd162f5349c7a04e2359fd1cf7400d39b0a0998)
+++ Invariant/test/utest_data_handling.py	(revision c75a8ed10188ecdc61e67bf33da877dab8980eb5)
@@ -281,4 +281,35 @@
         self.assertTrue(math.fabs(qs_extr-qstar)<dqs_extr)
         
+        def _check_values(to_check, reference, tolerance=0.05):
+            self.assertTrue( math.fabs(to_check-reference)/reference < tolerance, msg="Tested value = "+str(to_check) )
+            
+        # The following values should be replaced by values pulled from IGOR
+        # Volume Fraction:
+        v, dv = inv.get_volume_fraction_with_error(1, None)
+        _check_values(v, 1.88737914186e-15)
+
+        v_l, dv_l = inv.get_volume_fraction_with_error(1, 'low')
+        _check_values(v_l, 1.94289029309e-15)
+
+        v_h, dv_h = inv.get_volume_fraction_with_error(1, 'high')
+        _check_values(v_h, 6.99440505514e-15)
+        
+        v_b, dv_b = inv.get_volume_fraction_with_error(1, 'both')
+        _check_values(v_b, 6.99440505514e-15)
+        
+        # Specific Surface:
+        s, ds = inv.get_surface_with_error(1, 1, None)
+        _check_values(s, 3.1603095786e-09)
+
+        s_l, ds_l = inv.get_surface_with_error(1, 1, 'low')
+        _check_values(s_l, 3.1603095786e-09)
+
+        s_h, ds_h = inv.get_surface_with_error(1, 1, 'high')
+        _check_values(s_h, 3.1603095786e-09)
+        
+        s_b, ds_b = inv.get_surface_with_error(1, 1, 'both')
+        _check_values(s_b, 3.1603095786e-09)
+        
+        
     def test_bad_parameter_name(self):
         """
@@ -461,8 +492,7 @@
         
         qstar = inv.get_qstar(extrapolation='low')
-        reel_y = self.data.y
         test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x)
         for i in range(len(self.data.x)):
-            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
+            value  = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i]
             self.assert_(value < 0.001)
             
@@ -470,5 +500,5 @@
     """
         for a smear data, test that the fitting go through 
-        reel data for atleast the 2 first points
+        real data for atleast the 2 first points
     """
     
@@ -483,7 +513,5 @@
         y = numpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x])
         dy = y*.1
-        dxl = 0.117 * numpy.ones(len(x))
         self.data = Data1D(x=x, y=y, dy=dy)
-        self.data.dxl = dxl
         self.npts = len(x)-10
         
@@ -512,13 +540,10 @@
         
         qstar = inv.get_qstar(extrapolation='low')
-        reel_y = self.data.y
-        #Compution the y 's coming out of the invariant when computing extrapolated
-        #low data . expect the fit engine to have been already called and the guinier
-        # to have the radius and the scale fitted
+
         test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x[:inv._low_extrapolation_npts])
-        self.assert_(len(test_y))== len(reel_y[:inv._low_extrapolation_npts])
+        self.assert_(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts]))
         
         for i in range(inv._low_extrapolation_npts):
-            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
+            value  = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i]
             self.assert_(value < 0.001)
             
@@ -547,30 +572,20 @@
         
         qstar = inv.get_qstar(extrapolation='low')
-        reel_y = self.data.y
         #Compution the y 's coming out of the invariant when computing extrapolated
         #low data . expect the fit engine to have been already called and the guinier
         # to have the radius and the scale fitted
-        data_out_range, data_in_range= inv.get_extra_data_low() 
+        data_in_range = inv.get_extra_data_low(q_start=self.data.x[0], 
+                                               npts = inv._low_extrapolation_npts) 
         test_y = data_in_range.y
-        self.assert_(len(test_y))== len(reel_y[:inv._low_extrapolation_npts])
+        self.assert_(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts]))
         for i in range(inv._low_extrapolation_npts):
-            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
+            value  = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i]
             self.assert_(value < 0.001)    
-                    
-        data_out_range, data_in_range= inv.get_extra_data_low(npts_in= 2, nsteps=10,
-                                                               q_start= 1e-4) 
-        test_y = data_in_range.y
-        self.assert_(len(test_y))== len(reel_y[:2])
-        for i in range(2):
-            value  = math.fabs(test_y[i]-reel_y[i])/reel_y[i]
-            self.assert_(value < 0.001) 
-        #test the data out of range          
-        test_out_y = data_out_range.y
-        #self.assertEqual(len(test_out_y), 10)             
+       
             
 class TestDataExtraHighSlitPowerLaw(unittest.TestCase):
     """
         for a smear data, test that the fitting go through 
-        reel data for atleast the 2 first points
+        real data for atleast the 2 first points
     """
     
@@ -586,6 +601,4 @@
         dy = y*.1
         self.data = Data1D(x=x, y=y, dy=dy)
-        dxl = 0.117 * numpy.ones(len(x))
-        self.data.dxl = dxl
         self.npts = 20
         
@@ -616,15 +629,10 @@
         
         qstar = inv.get_qstar(extrapolation='high')
-        reel_y = self.data.y
-        #Compution the y 's coming out of the invariant when computing extrapolated
-        #low data . expect the fit engine to have been already called and the power law
-        # to have the radius and the scale fitted
-       
         
         test_y = inv._high_extrapolation_function.evaluate_model(x=self.data.x[start: ])
-        self.assert_(len(test_y))== len(reel_y[start:])
+        self.assert_(len(test_y) == len(self.data.y[start:]))
         
         for i in range(len(self.data.x[start:])):
-            value  = math.fabs(test_y[i]-reel_y[start+i])/reel_y[start+i]
+            value  = math.fabs(test_y[i]-self.data.y[start+i])/self.data.y[start+i]
             self.assert_(value < 0.001)
             
@@ -654,30 +662,13 @@
       
         qstar = inv.get_qstar(extrapolation='high')
-        reel_y = self.data.y
-        #Compution the y 's coming out of the invariant when computing extrapolated
-        #low data . expect the fit engine to have been already called and the power law
-        # to have the radius and the scale fitted
        
-        data_out_range, data_in_range= inv.get_extra_data_high() 
+        data_in_range= inv.get_extra_data_high(q_end = max(self.data.x),
+                                               npts = inv._high_extrapolation_npts) 
         test_y = data_in_range.y
-        self.assert_(len(test_y))== len(reel_y[start:])
-        temp = reel_y[start:]
+        self.assert_(len(test_y) == len(self.data.y[start:]))
+        temp = self.data.y[start:]
         
         for i in range(len(self.data.x[start:])):
             value  = math.fabs(test_y[i]- temp[i])/temp[i]
-            self.assert_(value < 0.001)    
-                    
-        data_out_range, data_in_range= inv.get_extra_data_high(npts_in=5, nsteps=10,
-                                                               q_end= 2) 
-        test_y = data_in_range.y
-        self.assert_(len(test_y)==5)
-        temp = reel_y[start:start+5]
-        
-        for i in range(len(self.data.x[start:start+5])):
-          
-            value  = math.fabs(test_y[i]- temp[i])/temp[i]
-            self.assert_(value < 0.06)    
-        #test the data out of range          
-        test_out_y = data_out_range.y
-        self.assertEqual(len(test_out_y), 10)             
+            self.assert_(value < 0.001)                
                       
