Index: src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py	(revision dc5ef150e8b37e01a3b7e253eb5b66d3b82de99c)
+++ src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py	(revision 06b013813a73a604c244f2a6011ebf796700910e)
@@ -10,4 +10,5 @@
 from sasmodels import generate
 from sasmodels import modelinfo
+from sasmodels.sasview_model import load_standard_models
 
 # Tested module
@@ -94,8 +95,15 @@
         # Use a single-shell parameter
         model_name = "barbell"
-        kernel_module = generate.load_kernel_module(model_name)
+        models = load_standard_models()
+
+        kernel_module = generate.load_kernel_module(model_name)
+        kernel_module_o = None
+        for model in models:
+            if model.name == model_name:
+                kernel_module_o = model()
+        self.assertIsNotNone(kernel_module_o)
         barbell_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
 
-        params = FittingUtilities.addParametersToModel(barbell_parameters, True)
+        params = FittingUtilities.addParametersToModel(barbell_parameters, kernel_module_o, True)
 
         # Test the resulting model
@@ -109,7 +117,12 @@
         model_name = "core_multi_shell"
         kernel_module = generate.load_kernel_module(model_name)
+        kernel_module_o = None
+        for model in models:
+            if model.name == model_name:
+                kernel_module_o = model()
+        self.assertIsNotNone(kernel_module_o)
         multi_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
 
-        params = FittingUtilities.addParametersToModel(multi_parameters, False)
+        params = FittingUtilities.addParametersToModel(multi_parameters, kernel_module_o, False)
 
         # Test the resulting model
@@ -127,7 +140,13 @@
         model_name = "core_multi_shell"
         kernel_module = generate.load_kernel_module(model_name)
+        models = load_standard_models()
+        kernel_module_o = None
+        for model in models:
+            if model.name == model_name:
+                kernel_module_o = model()
+        self.assertIsNotNone(kernel_module_o)
         multi_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
 
-        params = FittingUtilities.addParametersToModel(multi_parameters, True)
+        params = FittingUtilities.addParametersToModel(multi_parameters, kernel_module_o, True)
 
         # Test the resulting model
Index: src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py	(revision fd1ae6d13fef2c7657b038fea72a31b9f60b243a)
+++ src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py	(revision 06b013813a73a604c244f2a6011ebf796700910e)
@@ -35,5 +35,5 @@
         """Destroy the GUI"""
         self.widget.close()
-        self.widget = None
+        del self.widget
 
     def testDefaults(self):
@@ -84,8 +84,8 @@
         """
         Test if models have been loaded properly
-        :return:
         """
         fittingWindow =  self.widget
 
+        self.assertIsInstance(fittingWindow.lstPoly.itemDelegate(), QtGui.QStyledItemDelegate)
         #Test loading from json categories
         fittingWindow.SASModelToQModel("cylinder")
@@ -95,8 +95,14 @@
         self.assertEqual(str(pd_index.data().toString()), "Distribution of length")
 
+        # test the delegate a bit
+        delegate = fittingWindow.lstPoly.itemDelegate()
+        self.assertEqual(len(delegate.POLYDISPERSE_FUNCTIONS), 5)
+        self.assertEqual(delegate.POLY_EDITABLE_PARAMS, [2, 3, 4, 5])
+        self.assertEqual(delegate.POLY_FUNCTION, 6)
+        self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal)
+
     def testSelectStructureFactor(self):
         """
         Test if structure factors have been loaded properly
-        :return:
         """
         fittingWindow =  self.widget
@@ -340,4 +346,116 @@
             #self.assertTrue(isinstance(self.widget.lstPoly.indexWidget(func_index), QtGui.QComboBox))
             self.assertIn('Distribution of', self.widget._poly_model.item(row, 0).text())
+        #self.widget.close()
+
+    def testPolyModelChange(self):
+        """
+        Polydispersity model changed - test all possible scenarios
+        """
+        self.widget.show()
+        # Change the category index so we have a model with polydisp
+        category_index = self.widget.cbCategory.findText("Cylinder")
+        self.widget.cbCategory.setCurrentIndex(category_index)
+
+        # click on a poly parameter checkbox
+        index = self.widget._poly_model.index(0,0)
+        # Set the checbox
+        self.widget._poly_model.item(0,0).setCheckState(2)
+        # Assure the parameter is added
+        self.assertEqual(self.widget.parameters_to_fit, ['radius_bell.width'])
+
+        # Add another parameter
+        self.widget._poly_model.item(2,0).setCheckState(2)
+        # Assure the parameters are added
+        self.assertEqual(self.widget.parameters_to_fit, ['radius_bell.width', 'length.width'])
+
+        # Change the min/max values
+        self.assertEqual(self.widget.kernel_module.details['radius_bell'][1], 0.0)
+        self.widget._poly_model.item(0,2).setText("1.0")
+        self.assertEqual(self.widget.kernel_module.details['radius_bell'][1], 1.0)
+
+        # Change the number of points
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 35)
+        self.widget._poly_model.item(0,4).setText("22")
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 22)
+        # try something stupid
+        self.widget._poly_model.item(0,4).setText("butt")
+        # see that this didn't annoy the control at all
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 22)
+
+        # Change the number of sigmas
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 3)
+        self.widget._poly_model.item(0,5).setText("222")
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 222)
+        # try something stupid again
+        self.widget._poly_model.item(0,4).setText("beer")
+        # no efect
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 222)
+
+    def testOnPolyComboIndexChange(self):
+        """
+        Test the slot method for polydisp. combo box index change
+        """
+        self.widget.show()
+        # Change the category index so we have a model with polydisp
+        category_index = self.widget.cbCategory.findText("Cylinder")
+        self.widget.cbCategory.setCurrentIndex(category_index)
+
+        # call method with default settings
+        self.widget.onPolyComboIndexChange('gaussian', 0)
+        # check values
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 35)
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 3)
+        # Change the index
+        self.widget.onPolyComboIndexChange('rectangle', 0)
+        # check values
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 35)
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 1.70325)
+        # Change the index
+        self.widget.onPolyComboIndexChange('lognormal', 0)
+        # check values
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 80)
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 8)
+        # Change the index
+        self.widget.onPolyComboIndexChange('schulz', 0)
+        # check values
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.npts'), 80)
+        self.assertEqual(self.widget.kernel_module.getParam('radius_bell.nsigmas'), 8)
+
+        # mock up file load
+        self.widget.loadPolydispArray = MagicMock()
+        # Change to 'array'
+        self.widget.onPolyComboIndexChange('array', 0)
+        # See the mock fire
+        self.assertTrue(self.widget.loadPolydispArray.called)
+
+    def testLoadPolydispArray(self):
+        """
+        Test opening of the load file dialog for 'array' polydisp. function
+        """
+        filename = os.path.join("UnitTesting", "testdata_noexist.txt")
+        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename)
+        self.widget.show()
+        # Change the category index so we have a model with polydisp
+        category_index = self.widget.cbCategory.findText("Cylinder")
+        self.widget.cbCategory.setCurrentIndex(category_index)
+
+        self.widget.onPolyComboIndexChange('array', 0)
+        # check values - unchanged since the file doesn't exist
+        self.assertTrue(self.widget._poly_model.item(0, 1).isEnabled())
+        with self.assertRaises(AttributeError):
+            self.widget.disp_model()
+
+        # good file
+        filename = os.path.join("UnitTesting", "testdata.txt")
+        QtGui.QFileDialog.getOpenFileName = MagicMock(return_value=filename)
+
+        self.widget.onPolyComboIndexChange('array', 0)
+        # check values - disabled control, present weights
+        self.assertFalse(self.widget._poly_model.item(0, 1).isEnabled())
+        self.assertEqual(self.widget.disp_model.weights[0], 2.83954)
+        self.assertEqual(len(self.widget.disp_model.weights), 19)
+        self.assertEqual(len(self.widget.disp_model.values), 19)
+        self.assertEqual(self.widget.disp_model.values[0], 0.0)
+        self.assertEqual(self.widget.disp_model.values[18], 3.67347)
 
     def testSetMagneticModel(self):
