Index: src/sas/qtgui/GUITests.py
===================================================================
--- src/sas/qtgui/GUITests.py	(revision 811bec19d50f449dd2af46130143530ec1d535db)
+++ src/sas/qtgui/GUITests.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
@@ -32,4 +32,6 @@
 from Perspectives.Fitting.UnitTesting import FittingWidgetTest
 from Perspectives.Fitting.UnitTesting import FittingPerspectiveTest
+from Perspectives.Fitting.UnitTesting import FittingLogicTest
+from Perspectives.Fitting.UnitTesting import FittingUtilitiesTest
 
 
@@ -64,4 +66,6 @@
         unittest.makeSuite(FittingPerspectiveTest.FittingPerspectiveTest, 'test'),
         unittest.makeSuite(FittingWidgetTest.FittingWidgetTest, 'test'),
+        unittest.makeSuite(FittingLogicTest.FittingLogicTest, 'test'),
+        unittest.makeSuite(FittingUtilitiesTest.FittingUtilitiesTest, 'test'),
     )
     return unittest.TestSuite(suites)
Index: src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/FittingLogic.py	(revision 4d457df085e8cb849b74b751350edb791515f325)
+++ src/sas/qtgui/Perspectives/Fitting/FittingLogic.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
@@ -14,4 +14,7 @@
     def __init__(self, data=None):
         self._data = data
+        self.data_is_loaded = False
+        if data is not None:
+            self.data_is_loaded = True
 
     @property
@@ -119,6 +122,4 @@
 
         new_plot.group_id = data.group_id
-        if new_plot.group_id == None:
-            new_plot.group_id = data.group_id
         #new_plot.id = str(self.tab_id) + " " + data.name
         new_plot.name = model.name + " [" + data.name + "]"
Index: src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py	(revision 4d457df085e8cb849b74b751350edb791515f325)
+++ src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
@@ -74,5 +74,5 @@
     """
     for param in parameters.iq_parameters:
-        # Modify parameter name from <param>[n] to <param>1
+        # Create the top level, checkable item
         item_name = param.name
         item1 = QtGui.QStandardItem(item_name)
Index: src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
+++ src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
@@ -0,0 +1,154 @@
+import sys
+import unittest
+
+import numpy
+from mock import MagicMock
+
+# set up import paths
+import sas.qtgui.path_prepare
+
+# Local
+from sas.qtgui.GuiUtils import *
+from sas.qtgui.Perspectives.Fitting.FittingWidget import *
+from sas.sasgui.guiframe.dataFitting import Data1D
+
+app = QtGui.QApplication(sys.argv)
+
+
+class FittingLogicTest(unittest.TestCase):
+    """Test the fitting logic class"""
+
+    def setUp(self):
+        """Create the component"""
+        data = Data1D(x=[1,2,3],y=[3,4,5])
+        self.logic = FittingLogic(data=data)
+
+    def testDefaults(self):
+        """Test the component in its default state"""
+        self.assertIsInstance(self.logic.data, Data1D)
+        self.assertTrue(self.logic.data_is_loaded)
+        self.assertEqual(self.logic.data, self.logic._data)
+
+    def testComputeDataRange(self):
+        """
+        Tests the data range calculator on Data1D/Data2D
+        """
+        # Using the default data
+        qmin, qmax, npts = self.logic.computeDataRange()
+
+        self.assertEqual(qmin, 1)
+        self.assertEqual(qmax, 3)
+        self.assertEqual(npts, 3)
+
+        # data with more points
+        data = Data1D(x=[-10, 2, 10, 20],y=[-3, 4, 10, 50])
+        self.logic.data=data
+        qmin, qmax, npts = self.logic.computeDataRange()
+
+        self.assertEqual(qmin, -10)
+        self.assertEqual(qmax, 20)
+        self.assertEqual(npts, 4)
+
+    def testCreateDefault1dData(self):
+        """
+        Tests the default 1D set
+        """
+        interval = numpy.linspace(start=1, stop=10, num=10, endpoint=True)
+        self.logic.createDefault1dData(interval=interval)
+
+        self.assertEqual(self.logic.data.id, ('0 data'))
+        self.assertEqual(self.logic.data.group_id, ('0 Model1D'))
+        self.assertFalse(self.logic.data.is_data)
+        self.assertEqual(self.logic.data._xaxis, ('\\rm{Q}'))
+        self.assertEqual(self.logic.data._xunit, ('A^{-1}'))
+        self.assertEqual(self.logic.data._yaxis, ('\\rm{Intensity}'))
+        self.assertEqual(self.logic.data._yunit, ('cm^{-1}'))
+
+    def testCreateDefault2dData(self):
+        """
+        Tests the default 2D set
+        """
+        self.logic.createDefault2dData(qmax=0.35, qstep=50, tab_id=8)
+
+        self.assertEqual(self.logic.data.id, ('8 data'))
+        self.assertEqual(self.logic.data.group_id, ('8 Model2D'))
+        self.assertFalse(self.logic.data.is_data)
+        self.assertEqual(self.logic.data._xaxis, ('\\rm{Q_{x}}'))
+        self.assertEqual(self.logic.data._xunit, ('A^{-1}'))
+        self.assertEqual(self.logic.data._yaxis, ('\\rm{Q_{y}}'))
+        self.assertEqual(self.logic.data._yunit, ('A^{-1}'))
+
+        self.assertEqual(self.logic.data.xmin, -0.35)
+        self.assertEqual(self.logic.data.xmax, 0.35)
+
+        self.assertEqual(self.logic.data.ymin, -0.35)
+        self.assertEqual(self.logic.data.ymax, 0.35)
+
+        self.assertEqual(self.logic.data.data.sum(), 2500.0) # 50x50 array of 1's
+        self.assertEqual(self.logic.data.err_data.sum(axis=0), 2500.0)
+        self.assertAlmostEqual(self.logic.data.qx_data.sum(axis=0), 0.0)
+        self.assertAlmostEqual(self.logic.data.qy_data.sum(), 0.0)
+        self.assertAlmostEqual(self.logic.data.q_data.sum(), 683.106490, 6)
+        self.assertTrue(numpy.all(self.logic.data.mask))
+        self.assertAlmostEqual(self.logic.data.x_bins.sum(), 0.0)
+        self.assertAlmostEqual(self.logic.data.y_bins.sum(), 0.0)
+
+    def testNew1DPlot(self):
+        """
+        Test how the extra shells are presented
+        """
+        data = Data1D(x=[1,2,3],y=[3,4,5])
+        data.name = "boop"
+        return_data = (data.x,data.y, 7, None, None,
+                        0, True, 0.0, 1, data,
+                        data, False, None)
+
+        self.logic.new1DPlot(return_data=return_data)
+
+        self.assertIsInstance(self.logic.data, Data1D)
+        self.assertFalse(self.logic.data.is_data)
+        self.assertEqual(self.logic.data.dy.size, 3)
+        self.assertEqual(self.logic.data.title, "boop")
+        self.assertEqual(self.logic.data.name, "boop [boop]")
+
+    def testNew2DPlot(self):
+        """
+        Test the additional rows added by modifying the shells combobox
+        """
+        x_0 = 2.0*numpy.ones(25)
+        dx_0 = 0.5*numpy.ones(25)
+        qx_0 = numpy.arange(25)
+        qy_0 = numpy.arange(25)
+        mask_0 = numpy.zeros(25)
+        dqx_0 = numpy.arange(25)/100
+        dqy_0 = numpy.arange(25)/100
+        q_0 = numpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0)
+
+        data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0, 
+                      qy_data=qy_0, q_data=q_0, mask=mask_0, 
+                      dqx_data=dqx_0, dqy_data=dqy_0)
+
+        data.name = "boop"
+        data.ymin = numpy.amin(q_0)
+        data.ymax = numpy.amax(q_0)
+        data.xmin = numpy.amin(x_0)
+        data.xmax = numpy.amax(x_0)
+        self.logic.data = data
+
+        qmin, qmax, npts = self.logic.computeDataRange()
+
+        return_data = (x_0, data, 7, data, None,
+                        True, 0.0, 1, 0, qmin, qmax,
+                        0.1, False, None)
+
+        self.logic.new2DPlot(return_data=return_data)
+
+        self.assertIsInstance(self.logic.data, Data2D)
+        self.assertFalse(self.logic.data.is_data)
+        self.assertEqual(self.logic.data.title, "Analytical model 2D ")
+        self.assertEqual(self.logic.data.name, "boop [boop]")
+
+
+
+if __name__ == "__main__":
+    unittest.main()
Index: src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
+++ src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
@@ -0,0 +1,188 @@
+import sys
+import unittest
+from PyQt4 import QtGui
+
+from UnitTesting.TestUtils import WarningTestNotImplemented
+#from sasmodels.sasview_model import load_standard_models
+from sasmodels import generate
+from sasmodels import modelinfo
+
+# Tested module
+from sas.qtgui.Perspectives.Fitting import FittingUtilities
+
+class FittingUtilitiesTest(unittest.TestCase):
+    '''Test the Fitting Utilities functions'''
+    def setUp(self):
+        '''Empty'''
+        pass
+
+    def tearDown(self):
+        '''Empty'''
+        pass
+
+    def testReplaceShellName(self):
+        """
+        Test the utility function for string manipulation
+        """
+        param_name = "test [123]"
+        value = "replaced"
+        result = FittingUtilities.replaceShellName(param_name, value)
+        
+        self.assertEqual(result, "test replaced")
+
+        # Assert!
+        param_name = "no brackets"
+        with self.assertRaises(AssertionError):
+            result = FittingUtilities.replaceShellName(param_name, value)
+
+        
+    def testGetIterParams(self):
+        """
+        Assure the right multishell parameters are returned
+        """
+        # Use a single-shell parameter
+        model_name = "barbell"
+        kernel_module = generate.load_kernel_module(model_name)
+        barbell_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        params = FittingUtilities.getIterParams(barbell_parameters)
+        # returns empty list
+        self.assertEqual(params, [])
+
+        # Use a multi-shell parameter
+        model_name = "core_multi_shell"
+        kernel_module = generate.load_kernel_module(model_name)
+        multishell_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        params = FittingUtilities.getIterParams(multishell_parameters)
+        # returns a non-empty list
+        self.assertNotEqual(params, [])
+        self.assertIn('sld', str(params))
+        self.assertIn('thickness', str(params))
+
+    def testGetMultiplicity(self):
+        """
+        Assure more multishell parameters are evaluated correctly
+        """
+        # Use a single-shell parameter
+        model_name = "barbell"
+        kernel_module = generate.load_kernel_module(model_name)
+        barbell_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        param_name, param_length = FittingUtilities.getMultiplicity(barbell_parameters)
+        # returns nothing
+        self.assertEqual(param_name, "")
+        self.assertEqual(param_length, 0)
+
+        # Use a multi-shell parameter
+        model_name = "core_multi_shell"
+        kernel_module = generate.load_kernel_module(model_name)
+        multishell_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        param_name, param_length = FittingUtilities.getMultiplicity(multishell_parameters)
+
+        self.assertEqual(param_name, "n")
+        self.assertEqual(param_length, 10)
+
+    def testAddParametersToModel(self):
+        """
+        Checks the QModel update from Sasmodel parameters
+        """
+        # Use a single-shell parameter
+        model_name = "barbell"
+        kernel_module = generate.load_kernel_module(model_name)
+        barbell_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        model = QtGui.QStandardItemModel()
+
+        FittingUtilities.addParametersToModel(barbell_parameters, model)
+
+        # Test the resulting model
+        self.assertEqual(model.rowCount(), 5)
+        self.assertTrue(model.item(0).isCheckable())
+        self.assertEqual(model.item(0).text(), "sld")
+        self.assertEqual(model.item(1).text(), "sld_solvent")
+
+        # Use a multi-shell parameter to see that the method includes shell params
+        model_name = "core_multi_shell"
+        kernel_module = generate.load_kernel_module(model_name)
+        multi_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        model = QtGui.QStandardItemModel()
+
+        FittingUtilities.addParametersToModel(multi_parameters, model)
+
+        # Test the resulting model
+        self.assertEqual(model.rowCount(), 5)
+        self.assertTrue(model.item(0).isCheckable())
+        self.assertEqual(model.item(0).text(), "sld_core")
+        self.assertFalse(model.item(3).hasChildren())
+        self.assertEqual(model.item(1).text(), "radius")
+        self.assertEqual(model.item(2).text(), "sld_solvent")
+        self.assertEqual(model.item(3).text(), "sld1")
+
+        self.assertEqual(model.item(4).text(), "thickness1")
+        self.assertTrue(model.item(4).hasChildren())
+
+    def testAddSimpleParametersToModel(self):
+        """
+        Checks the QModel update from Sasmodel parameters - no polydisp
+        """
+        # Use a multi-shell parameter to see that the method doesn't include shells
+        model_name = "core_multi_shell"
+        kernel_module = generate.load_kernel_module(model_name)
+        multi_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        model = QtGui.QStandardItemModel()
+
+        FittingUtilities.addParametersToModel(multi_parameters, model)
+
+        # Test the resulting model
+        self.assertEqual(model.rowCount(), 5)
+        self.assertTrue(model.item(0).isCheckable())
+        self.assertEqual(model.item(0).text(), "sld_core")
+        self.assertEqual(model.item(1).text(), "radius")
+
+    def testAddCheckedListToModel(self):
+        """
+        Test for inserting a checkboxed item into a QModel
+        """
+        model = QtGui.QStandardItemModel()
+        params = ["row1", "row2", "row3"]
+
+        FittingUtilities.addCheckedListToModel(model, params)
+
+        # Check the model
+        self.assertEqual(model.rowCount(), 1)
+        self.assertTrue(model.item(0).isCheckable())
+        self.assertEqual(model.item(0, 0).text(), params[0])
+        self.assertEqual(model.item(0, 1).text(), params[1])
+        self.assertEqual(model.item(0, 2).text(), params[2])
+
+    def testAddShellsToModel(self):
+        """
+        Test for inserting a list of QItems into a model
+        """
+        # Use a multi-shell parameter to see that the method doesn't include shells
+        model_name = "core_multi_shell"
+        kernel_module = generate.load_kernel_module(model_name)
+        multi_parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', []))
+
+        model = QtGui.QStandardItemModel()
+
+        index = 2
+        FittingUtilities.addShellsToModel(multi_parameters, model, index)
+        # There should be index*len(multi_parameters) new rows
+        self.assertEqual(model.rowCount(), 4)
+
+        model = QtGui.QStandardItemModel()
+        index = 5
+        FittingUtilities.addShellsToModel(multi_parameters, model, index)
+        self.assertEqual(model.rowCount(), 10)
+        
+        self.assertEqual(model.item(1).child(0).text(), "Polydispersity")
+        self.assertEqual(model.item(1).child(0).child(0).text(), "Distribution")
+        self.assertEqual(model.item(1).child(0).child(0,1).text(), "40.0")
+
+if __name__ == "__main__":
+    unittest.main()
Index: src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
===================================================================
--- src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py	(revision 811bec19d50f449dd2af46130143530ec1d535db)
+++ src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py	(revision 7248d75d0e91daa6e6c6163bb53fa76c1c8898e3)
@@ -71,9 +71,9 @@
         item = QtGui.QStandardItem("test")
 
-        widget_with_data = FittingWidget(dummy_manager(), data=[data], id=3)
+        widget_with_data = FittingWidget(dummy_manager(), data=[item], id=3)
 
         self.assertEqual(widget_with_data.data, data)
         self.assertTrue(widget_with_data.data_is_loaded)
-        self.assertTrue(widget_with_data.cmdFit.isEnabled())
+        # self.assertTrue(widget_with_data.cmdFit.isEnabled())
         self.assertFalse(widget_with_data.acceptsData())
 
@@ -125,5 +125,5 @@
 
         #Test loading from json categories
-        fittingWindow.setModelModel("cylinder")
+        fittingWindow.SASModelToQModel("cylinder")
         pd_index = fittingWindow.lstPoly.model().index(0,0)
         self.assertEqual(str(pd_index.data().toString()), "Distribution of radius")
@@ -177,22 +177,4 @@
         pass
 
-    def testGetIterParams(self):
-        """
-        Assure the right multishell parameters are returned
-        """
-        pass
-
-    def testGetMultiplicity(self):
-        """
-        Assure more multishell parameters are evaluated correctly
-        """
-        pass
-
-    def testAddCheckedListToModel(self):
-        """
-        Test for utility function
-        """
-        pass
-
     def testUpdateParamsFromModel(self):
         """
@@ -207,16 +189,4 @@
         pass
 
-    def testAddParametersToModel(self):
-        """
-        Checks the QModel update from Sasmodel parameters
-        """
-        pass
-
-    def testAddSimpleParametersToModel(self):
-        """
-        Checks the QModel update from Sasmodel parameters - no polydisp
-        """
-        pass
-
     def testCreateDefault1dData(self):
         """
@@ -258,10 +228,4 @@
         """
         Check that a new 2D plot is generated
-        """
-        pass
-
-    def testReplaceShellName(self):
-        """
-        Test the utility function for string manipulation
         """
         pass
