initial refactoring
diff --git a/olt.py b/olt.py
index 4f78f2a..2c36d58 100644
--- a/olt.py
+++ b/olt.py
@@ -5,9 +5,11 @@
 import logging
 from __builtin__ import xrange
 from oftest import config
+from oltbase import OltBaseTest
 import oftest.base_tests as base_tests
 import oftest.packet as scapy
 
+
 import ofp
 import time
 import copy
@@ -832,7 +834,13 @@
         self.assertTrue(len(stats) == 4, \
                         "Wrong number of rules reports; reported %s, expected 4\n\n %s" % (len(stats), stats))
 
-        logging.info(stats)
+        eapol = ofp.oxm.eth_type(0x888e)
+        found = False
+        for fe in stats:
+            if eapol in fe.match.oxm_list:
+                found = True
+
+        self.assertFalse(found, "Removed incorrect flow rule")
 
 
 class MultipleDoubleTaggingForwarding(base_tests.SimpleDataPlane):
@@ -842,7 +850,7 @@
         pass
 
 
-class DoubleVlanTest(base_tests.SimpleDataPlane):
+class DoubleVlanTest(OltBaseTest):
 
     def runTest(self):
         logging.info("Running double vlan tests")
@@ -851,7 +859,7 @@
         c_vlan_id = 100
         s_vlan_id = 102
 
-        installDoubleTaggingRules(s_vlan_id, c_vlan_id, self.controller)
+        self.installDoubleTaggingRules(s_vlan_id, c_vlan_id)
 
         # It takes some time for flows to propagate down to the data plane
         time.sleep(10)
@@ -950,108 +958,3 @@
     verify_no_packet(test, upstreamDoubleTaggedPkt, olt_port)
 
 
-def installDoubleTaggingRules(s_vlan_id, c_vlan_id, controller, cookie=42):
-
-    # upstream flow rule
-    match = ofp.match()
-    match.oxm_list.append(ofp.oxm.in_port(onu_port))
-    if device_type == "cpqd":
-        match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
-        actions = [
-            ofp.action.push_vlan(ethertype=0x8100),
-            ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id)),
-            ofp.action.set_field(ofp.oxm.vlan_pcp(0))
-        ]
-    else:  # "pmc", "normal"
-        match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_PRESENT))
-        match.oxm_list.append(ofp.oxm.vlan_pcp(value=0))
-        actions = [
-            ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
-        ]
-    cookie += 1
-
-    # push inner vlan (c-vlan) for upstream
-    request = ofp.message.flow_add(
-        table_id=test_param_get("table", 0),
-        cookie=cookie,
-        match=match,
-        instructions=[
-            ofp.instruction.apply_actions(actions=actions),
-            ofp.instruction.goto_table(1)],
-        buffer_id=ofp.OFP_NO_BUFFER,
-        priority=1000)
-
-    controller.message_send(request)
-    do_barrier(controller)
-    verify_no_errors(controller)
-
-    # push outer vlan (s-vlan) for upstream
-    match = ofp.match()
-    match.oxm_list.append(ofp.oxm.in_port(onu_port))
-    match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
-    match.oxm_list.append(ofp.oxm.vlan_pcp(0))
-    cookie += 1
-
-    request = ofp.message.flow_add(
-        table_id=test_param_get("table", 1),
-        cookie=cookie,
-        match=match,
-        instructions=[
-            ofp.instruction.apply_actions(
-                actions=[
-                    ofp.action.push_vlan(ethertype=0x8100),
-                    ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id)),
-                    ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
-                    ofp.action.output(port=olt_port)]),
-        ],
-        buffer_id=ofp.OFP_NO_BUFFER,
-        priority=1000)
-
-    controller.message_send(request)
-    do_barrier(controller)
-    verify_no_errors(controller)
-    cookie += 1
-
-    # strip outer vlan (s-vlan) for downstream
-    match = ofp.match()
-    match.oxm_list.append(ofp.oxm.in_port(olt_port))
-    match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id))
-    match.oxm_list.append(ofp.oxm.vlan_pcp(0))
-    request = ofp.message.flow_add(
-        table_id=test_param_get("table", 0),
-        cookie=cookie,
-        match=match,
-        instructions=[
-            ofp.instruction.apply_actions(
-                actions=[ofp.action.pop_vlan()]),
-            ofp.instruction.goto_table(1)],
-        buffer_id=ofp.OFP_NO_BUFFER,
-        priority=1000)
-
-    controller.message_send(request)
-    do_barrier(controller)
-    verify_no_errors(controller)
-
-    # rewrite inner vlan (c-vlan) to default (0) for downstream
-    match = ofp.match()
-    match.oxm_list.append(ofp.oxm.in_port(olt_port))
-    match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
-    match.oxm_list.append(ofp.oxm.vlan_pcp(0))
-    cookie += 1
-
-    request = ofp.message.flow_add(
-        table_id=test_param_get("table", 1),
-        cookie=cookie,
-        match=match,
-        instructions=[
-            ofp.instruction.apply_actions(
-                actions=[
-                    ofp.action.pop_vlan(),
-                    ofp.action.output(port=onu_port)])
-        ],
-        buffer_id=ofp.OFP_NO_BUFFER,
-        priority=1000)
-
-    controller.message_send(request)
-    do_barrier(controller)
-    verify_no_errors(controller)
diff --git a/oltbase.py b/oltbase.py
new file mode 100644
index 0000000..642d5c2
--- /dev/null
+++ b/oltbase.py
@@ -0,0 +1,114 @@
+import oftest.base_tests as base_tests
+import oftest.packet as scapy
+
+import ofp
+import time
+
+
+class OltBaseTest(base_tests.SimpleDataPlane):
+
+    def installDoubleTaggingRules(s_vlan_id, c_vlan_id, cookie=42):
+
+        # upstream flow rule
+        match = ofp.match()
+        match.oxm_list.append(ofp.oxm.in_port(onu_port))
+        if device_type == "cpqd":
+            match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_NONE))
+            actions = [
+                ofp.action.push_vlan(ethertype=0x8100),
+                ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id)),
+                ofp.action.set_field(ofp.oxm.vlan_pcp(0))
+            ]
+        else:  # "pmc", "normal"
+            match.oxm_list.append(ofp.oxm.vlan_vid(value=ofp.OFPVID_PRESENT))
+            match.oxm_list.append(ofp.oxm.vlan_pcp(value=0))
+            actions = [
+                ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
+            ]
+        cookie += 1
+
+        # push inner vlan (c-vlan) for upstream
+        request = ofp.message.flow_add(
+            table_id=test_param_get("table", 0),
+            cookie=cookie,
+            match=match,
+            instructions=[
+                ofp.instruction.apply_actions(actions=actions),
+                ofp.instruction.goto_table(1)],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1000)
+
+        self.controller.message_send(request)
+        do_barrier(self.controller)
+        verify_no_errors(self.controller)
+
+        # push outer vlan (s-vlan) for upstream
+        match = ofp.match()
+        match.oxm_list.append(ofp.oxm.in_port(onu_port))
+        match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
+        match.oxm_list.append(ofp.oxm.vlan_pcp(0))
+        cookie += 1
+
+        request = ofp.message.flow_add(
+            table_id=test_param_get("table", 1),
+            cookie=cookie,
+            match=match,
+            instructions=[
+                ofp.instruction.apply_actions(
+                    actions=[
+                        ofp.action.push_vlan(ethertype=0x8100),
+                        ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id)),
+                        ofp.action.set_field(ofp.oxm.vlan_pcp(0)),
+                        ofp.action.output(port=olt_port)]),
+            ],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1000)
+
+        self.controller.message_send(request)
+        do_barrier(self.controller)
+        verify_no_errors(self.controller)
+        cookie += 1
+
+        # strip outer vlan (s-vlan) for downstream
+        match = ofp.match()
+        match.oxm_list.append(ofp.oxm.in_port(olt_port))
+        match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | s_vlan_id))
+        match.oxm_list.append(ofp.oxm.vlan_pcp(0))
+        request = ofp.message.flow_add(
+            table_id=test_param_get("table", 0),
+            cookie=cookie,
+            match=match,
+            instructions=[
+                ofp.instruction.apply_actions(
+                    actions=[ofp.action.pop_vlan()]),
+                ofp.instruction.goto_table(1)],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1000)
+
+        self.controller.message_send(request)
+        do_barrier(self.controller)
+        verify_no_errors(self.controller)
+
+        # rewrite inner vlan (c-vlan) to default (0) for downstream
+        match = ofp.match()
+        match.oxm_list.append(ofp.oxm.in_port(olt_port))
+        match.oxm_list.append(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | c_vlan_id))
+        match.oxm_list.append(ofp.oxm.vlan_pcp(0))
+        cookie += 1
+
+        request = ofp.message.flow_add(
+            table_id=test_param_get("table", 1),
+            cookie=cookie,
+            match=match,
+            instructions=[
+                ofp.instruction.apply_actions(
+                    actions=[
+                        ofp.action.pop_vlan(),
+                        ofp.action.output(port=onu_port)])
+            ],
+            buffer_id=ofp.OFP_NO_BUFFER,
+            priority=1000)
+
+        self.controller.message_send(request)
+        do_barrier(self.controller)
+        verify_no_errors(self.controller)