diff --git a/bluez/ubt b/bluez/ubt
index 23e36a931172e8be111ad3d5bb16081fd813351d..a314046af947f2ba8696c9a62aedae11aa05386b 100755
--- a/bluez/ubt
+++ b/bluez/ubt
@@ -446,40 +446,41 @@ class PbapDeviceProfileTester(DeviceProfileTester):
             signal_name="PropertiesChanged",
             path_keyword='path')
 
+    def __test_dun_pan(self, path):
+        bus = dbus.SystemBus()
+
+        manager = dbus.Interface(bus.get_object("net.connman", "/"),
+                                 "net.connman.Manager")
+        services = manager.GetServices()
+
+        device_name = self._device_obj.Get(
+            'org.bluez.Device1',
+            'Name',
+            dbus_interface='org.freedesktop.DBus.Properties')
+
+        path = None
+        for s in services:
+            if s[1]["Name"] == device_name:
+                path = s[0]
+                break
+        if not path:
+            raise
+
+        service = dbus.Interface(bus.get_object("net.connman", path),
+                                 "net.connman.Service")
+        service.Connect(timeout=60000)
+        url = urllib.request.urlopen("http://connman.net")
+        f = open(path, 'w')
+        f.write(url.read(1000000))
+        f.close()
+        service.Disconnect(timeout=60000)
+
     def test_dun(self):
         TEST_START("DUN GW")
 
         try:
-            bus = dbus.SystemBus()
-
-            manager = dbus.Interface(bus.get_object("net.connman", "/"),
-                                     "net.connman.Manager")
-            services = manager.GetServices()
-
-            device_name = self._device_obj.Get(
-                'org.bluez.Device1',
-                'Name',
-                dbus_interface='org.freedesktop.DBus.Properties')
-
-            path = None
-            for s in services:
-                if s[1]["Name"] == device_name:
-                    path = s[0]
-                    break
-            if not path:
-                raise
-
-            service = dbus.Interface(bus.get_object("net.connman", path),
-                                     "net.connman.Service")
-            service.Connect(timeout=60000)
-            url = urllib.request.urlopen("http://connman.net")
-            f = open(BASE_PATH + "/DUN", 'w')
-            f.write(url.read(1000000))
-            f.close()
-            service.Disconnect(timeout=60000)
-
+            self.__test_dun_pan(BASE_PATH + "/DUN")
             TEST_PASSED("DUN GW")
-
         except Exception as error:
             TEST_FAILED("DUN GW: " + str(error))
 
@@ -489,36 +490,7 @@ class PbapDeviceProfileTester(DeviceProfileTester):
         TEST_START("PAN NAP")
 
         try:
-            bus = dbus.SystemBus()
-
-            manager = dbus.Interface(bus.get_object("net.connman", "/"),
-                                     "net.connman.Manager")
-
-            services = manager.GetServices()
-
-            device_name = self._device_obj.Get(
-                'org.bluez.Device1',
-                'Name',
-                dbus_interface='org.freedesktop.DBus.Properties')
-
-            path = None
-            for s in services:
-                if s[1]["Name"] == device_name:
-                    path = s[0]
-                    break
-            if not path:
-                raise
-
-            service = dbus.Interface(bus.get_object("net.connman", path),
-                                     "net.connman.Service")
-
-            service.Connect(timeout=60000)
-            url = urllib2.urlopen("http://connman.net")
-            f = open(BASE_PATH + "/PAN", 'w')
-            f.write(url.read(1000000))
-            f.close()
-            service.Disconnect(timeout=60000)
-
+            self.__test_dun_pan(BASE_PATH + "/PAN")
             TEST_PASSED("PAN NAP")
         except Exception as error:
             TEST_FAILED("PAN NAP: " + str(error))