Index: sansmodels/src/sans/models/FractalModel.py
===================================================================
--- sansmodels/src/sans/models/FractalModel.py	(revision f629e346291dbccc6f799045adc85db8e542bdf8)
+++ sansmodels/src/sans/models/FractalModel.py	(revision 36948c921d9d5d3627d4ffc58ffa2c6440002c3a)
@@ -49,10 +49,10 @@
         ## Parameter details [units, min, max]
         self.details = {}
-        self.details['scale']       = ['', None, None]
-        self.details['radius']      = ['A', None, None]
-        self.details['fractal_dim'] = ['', None, None]
-        self.details['corr_length'] = ['A', None, None]
-        self.details['block_sld']   = ['A-2', None, None]
-        self.details['solvent_sld'] = ['A-2', None, None]
+        self.details['scale']       = ['',     None, None]
+        self.details['radius']      = ['A',    None, None]
+        self.details['fractal_dim'] = ['',       0,  None]
+        self.details['corr_length'] = ['A',    None, None]
+        self.details['block_sld']   = ['A-2',  None, None]
+        self.details['solvent_sld'] = ['A-2',  None, None]
         self.details['background']  = ['cm-1', None, None]
        
@@ -63,10 +63,11 @@
             F(x) = p(x) * s(x) + bkd  
         """
+        if x<0 and self.params['fractal_dim']>0:
+            raise ValueError, "negative number cannot be raised to a fractional power"
+
         return self.params['background']+ self._scatterRanDom(x)* self._Block(x)
+
     
     def _Block(self,x):
-        
-        
-        
         return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\
              * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\
@@ -96,5 +97,10 @@
         """
         if x.__class__.__name__ == 'list':
-            return self._Fractal(x[0]*math.cos(x[1]))*self._Fractal(x[0]*math.sin(x[1]))
+            # Take absolute value of Q, since this model is really meant to
+            # be defined in 1D for a given length of Q
+            qx = math.fabs(x[0]*math.cos(x[1]))
+            qy = math.fabs(x[0]*math.sin(x[1]))
+            
+            return self._Fractal(qx)*self._Fractal(qy)
         elif x.__class__.__name__ == 'tuple':
             raise ValueError, "Tuples are not allowed as input to BaseComponent models"
Index: sansmodels/src/sans/models/PorodModel.py
===================================================================
--- sansmodels/src/sans/models/PorodModel.py	(revision 3db389570c206a21d9ba5706da8726e27ff899b6)
+++ sansmodels/src/sans/models/PorodModel.py	(revision 36948c921d9d5d3627d4ffc58ffa2c6440002c3a)
@@ -26,14 +26,16 @@
         ## Define parameters
         self.params = {}
-        self.params['scale'] = 0.0
+        self.params['scale'] = 1.0
+        self.params['background'] = 0.0
         
 
         ## Parameter details [units, min, max]
         self.details = {}
-        self.details['scale'] = ['', None, None]
+        self.details['scale']      = ['', None, None]
+        self.details['background'] = ['', None, None]
       
                
     def _porod(self, x):
-        return self.params['scale']/x**4.0
+        return self.params['scale']/x**4.0 + self.params['background']
    
     def run(self, x = 0.0):
Index: sansmodels/src/sans/models/PowerLawModel.py
===================================================================
--- sansmodels/src/sans/models/PowerLawModel.py	(revision 3db389570c206a21d9ba5706da8726e27ff899b6)
+++ sansmodels/src/sans/models/PowerLawModel.py	(revision 36948c921d9d5d3627d4ffc58ffa2c6440002c3a)
@@ -38,5 +38,5 @@
         ## Parameter details [units, min, max]
         self.details = {}
-        self.details['m']           = ['', None, None ]
+        self.details['m']           = ['', 0,    None]
         self.details['scale']       = ['', None, None]
         self.details['background']  = ['', None, None]
@@ -47,8 +47,10 @@
            
         """
-        return self.params['scale']*math.pow(x ,-self.params['m'])\
+        if x<0 and self.params['m']>0:
+            raise ValueError, "negative number cannot be raised to a fractional power"
+        
+        return self.params['scale']*math.pow(x ,-1.0*self.params['m'])\
                 + self.params['background']
        
-   
     def run(self, x = 0.0):
         """ Evaluate the model
@@ -57,5 +59,9 @@
         """
         if x.__class__.__name__ == 'list':
-            return self._PowerLaw(x[0]*math.cos(x[1]))*self._PowerLaw(x[0]*math.sin(x[1]))
+            # Take absolute value of Q, since this model is really meant to
+            # be defined in 1D for a given length of Q
+            qx = math.fabs(x[0]*math.cos(x[1]))
+            qy = math.fabs(x[0]*math.sin(x[1]))
+            return self._PowerLaw(qx)*self._PowerLaw(qy)
         elif x.__class__.__name__ == 'tuple':
             raise ValueError, "Tuples are not allowed as input to BaseComponent models"
Index: sansmodels/src/sans/models/test/testcase_generator.py
===================================================================
--- sansmodels/src/sans/models/test/testcase_generator.py	(revision ae3ce4eaa593202ebf49122e196897c0d45a25b6)
+++ sansmodels/src/sans/models/test/testcase_generator.py	(revision 36948c921d9d5d3627d4ffc58ffa2c6440002c3a)
@@ -344,4 +344,5 @@
         
         if not self.passed:
+            print "\nFailure:"
             print report.trace
         return self.passed
@@ -353,6 +354,6 @@
         @return: True if passed, False otherwise
     """
-    minval = 0
-    maxval = 20
+    minval = 0.001
+    maxval = 1.0
     # Call run with random input
     import random, math
@@ -368,5 +369,6 @@
             output = model.run([input_value, 2*math.pi*random.random()])            
     except ZeroDivisionError:
-        output = -1
+        print "Error evaluating model %s: %g" % (model.name, input_value)
+        output = None
         
     #print "Eval: %g" % output
@@ -374,6 +376,10 @@
     # Oracle bit - just check that we have a number...
     passed = False
-    if math.fabs(output) >= 0: 
-        passed = True
+    try:
+        if output != None and math.fabs(output) >= 0: 
+            passed = True
+    except:
+        print "---> Could not compute abs val", output, model.name
+        
     
     report = ReportCard()
@@ -382,7 +388,7 @@
         report.n_eval_pass = 1
     else:
-        report.log = "Eval: bad output value %g\n" % output
-        
-    report.trace = "Eval(%g) = %g %i\n" % (input_value, output, passed)    
+        report.log = "Eval: bad output value %s\n" % str(output)
+        
+    report.trace = "Eval(%g) = %s %i\n" % (input_value, str(output), passed)    
     return model, report
 
@@ -395,5 +401,5 @@
     import random, math
     minval = 1
-    maxval = 50
+    maxval = 5
     
     # Choose a parameter to change
@@ -407,5 +413,23 @@
     p_name  = keys[i_param]
     
-    # Chose a value
+    # Choose a value
+    # Check for min/max
+    if hasattr(model, "details"):
+        if model.details.has_key(p_name):
+            if model.details[p_name][1] != None:
+                minval = model.details[p_name][1]
+            if model.details[p_name][2] != None:
+                maxval = model.details[p_name][2]
+        elif model.other.details.has_key(p_name):
+            if model.other.details[p_name][1] != None:
+                minval = model.other.details[p_name][1]
+            if model.other.details[p_name][2] != None:
+                maxval = model.other.details[p_name][2]
+        elif model.operateOn.details.has_key(p_name):
+            if model.operateOn.details[p_name][1] != None:
+                minval = model.operateOn.details[p_name][1]
+            if model.operateOn.details[p_name][2] != None:
+                maxval = model.operateOn.details[p_name][2]
+            
     input_val = random.random()*(maxval-minval)+minval
     model.setParam(p_name, input_val)
@@ -613,7 +637,8 @@
     
     try:
-        value2 = tmp.run(1)
+        value2 = tmp.run(1.1 * (1.0 + random()))
         value2 = float(value2)
     except:
+        value2 = None
         passed = False
     
@@ -628,7 +653,7 @@
         report.log = "Sub: bad output from composite model\n"
 
-    report.trace = "Sub %s (%g - %g = %g) %i\n" % \
+    report.trace = "Sub %s (%g - %g = %s) %i\n" % \
         (model.name, model.run(1), \
-         sub_model.run(1), value2, passed)                
+         sub_model.run(1), str(value2), passed)                
     return tmp, report
 
@@ -647,10 +672,16 @@
     # Oracle bit
     passed = False
-
+    
+    from random import random
+    input_val = 1.1 * (1.0 + random())
+    v1 = None
+    v2 = None
     try:
-        value2 = tmp.run(1)
+        v1 = mul_model.run(input_val)
+        v2 = model.run(input_val)
+        value2 = tmp.run(input_val)
         value2 = float(value2)
-    except:
-        passed = False
+    except ZeroDivisionError:
+        value2 = None
     
     # If we made it this far, we have a float
@@ -664,7 +695,6 @@
         report.log = "Mul: bad output from composite model\n"
         
-    report.trace = "Mul %s (%g * %g = %g) %i\n" % \
-      (model.name, model.run(1), \
-       mul_model.run(1), value2, passed)                
+    report.trace = "Mul %s (%s * %s = %s) %i\n" % \
+      (model.name, str(v1), str(v2), str(value2), passed)                
     return tmp, report
 
@@ -678,6 +708,19 @@
     #div_model = factory.getModel("SphereModel")
     #div_model = factory.getModel(randomModel())
-    div_model = getRandomModelObject()
-    
+
+    from random import random
+    input_val = 1.5 * random()
+    
+    # Find a model that will not evaluate to zero
+    # at the input value
+    try_again = True
+    while try_again:
+        div_model = getRandomModelObject()
+        try:
+            v2 = div_model.run(input_val)
+            try_again = False
+        except:
+            pass
+        
     tmp = model / div_model
     
@@ -685,12 +728,18 @@
     passed = False
     
+    v1 = None
+    v2 = None
     try:
-        from random import random
-        input_val = 1.5 * random()
-        if div_model.run(input_val)==0:
-            print "Skipped (DIV) because denominator evaluated to zero"
-        else:
+        
+        # Check individual models against bad combinations,
+        # which happen from time to time given that all 
+        # parameters are random
+        try:
+            v2 = div_model.run(input_val)
+            v1 = model.run(input_val)
             value2 = tmp.run(input_val)
             value2 = float(value2)
+        except ZeroDivisionError:
+            value2 = None
     except:
         passed = False
@@ -706,7 +755,6 @@
         report.log = "Div: bad output from composite model\n"
         
-    report.trace = "Div %s (%g / %g = %g) %i\n" % \
-        (model.name, model.run(1), \
-         div_model.run(1), value2, passed)                
+    report.trace = "Div %s/%s (%g) = %s / %s = %s %i\n" % \
+      (model.name, div_model.name, input_val, str(v1), str(v2), str(value2), passed)                
     return tmp, report
 
@@ -715,5 +763,5 @@
     #print randomModel()
     g = TestCaseGenerator()
-    g.generateAndRun(2000)
+    g.generateAndRun(20000)
     
     #t = TestCase(filename = "error_1.17721e+009.xml")
