diff --git a/inventory_provider/db/opsdb.py b/inventory_provider/db/opsdb.py
index b39e51e741c664abc87f9cfab45d2340d74b0103..00ce299b4ce403f63499ea4427975df1195bc744 100644
--- a/inventory_provider/db/opsdb.py
+++ b/inventory_provider/db/opsdb.py
@@ -1,8 +1,5 @@
 from inventory_provider.db import db
 
-
-
-
 geant_lambda_sql = """SELECT
                       absid AS id,
                       name,
@@ -297,6 +294,21 @@ SELECT
 
     def _fields2rsp(row):
 
+        def _pop(r, suffix):
+            return {
+                'name': r['equipment_name' + suffix],
+                'card id': r['card_id' + suffix],
+                'port number': r['port' + suffix],
+                'pop': {
+                    'absid': r['pop_absid' + suffix],
+                    'name': r['pop_name' + suffix],
+                    'city': r['pop_city' + suffix],
+                    'country': r['pop_country' + suffix],
+                    'abbreviation': r['pop_abbreviation' + suffix],
+                    'longitude': r['pop_longitude' + suffix],
+                    'latitude': r['pop_latitude' + suffix]
+                }
+            }
 
         return {
             'absid': row['absid'],
@@ -306,34 +318,8 @@ SELECT
             'peering_type': row['peering_type'],
             'status': row['status'],
             'name': row['name'],
-            'a': {
-                'name': row['equipment_name_a'],
-                'card id': row['card_id_a'],
-                'port number': row['port_a'],
-                'pop': {
-                    'absid': row['pop_absid_a'],
-                    'name': row['pop_name_a'],
-                    'city': row['pop_city_a'],
-                    'country': row['pop_country_a'],
-                    'abbreviation': row['pop_abbreviation_a'],
-                    'longitude': row['pop_longitude_a'],
-                    'latitude': row['pop_latitude_a']
-                }
-            },
-            'b': {
-                'name': row['equipment_name_b'],
-                'card id': row['card_id_b'],
-                'port number': row['port_b'],
-                'pop': {
-                    'absid': row['pop_absid_b'],
-                    'name': row['pop_name_b'],
-                    'city': row['pop_city_b'],
-                    'country': row['pop_country_b'],
-                    'abbreviation': row['pop_abbreviation_b'],
-                    'longitude': row['pop_longitude_b'],
-                    'latitude': row['pop_latitude_b']
-                }
-            }
+            'a': _pop(row, '_a'),
+            'b': _pop(row, '_b'),
         }
 
     circuit_query = base_query + """
diff --git a/inventory_provider/routes/data.py b/inventory_provider/routes/data.py
index 6eef23b86a31c64e6b6a1568693a5a1d609484a1..258f05ea1352c3e4b73c79c2ad3f4caceb935b5f 100644
--- a/inventory_provider/routes/data.py
+++ b/inventory_provider/routes/data.py
@@ -56,7 +56,3 @@ def equipment_location(equipment_name):
             mimetype="text/html")
 
     return jsonify(result)
-
-
-
-
diff --git a/inventory_provider/routes/jobs.py b/inventory_provider/routes/jobs.py
index 9fd9d3f235cabcb98f4e4148045d37da489ab345..a02ddea1582347b1296deb1aac797054e5694aca 100644
--- a/inventory_provider/routes/jobs.py
+++ b/inventory_provider/routes/jobs.py
@@ -1,4 +1,4 @@
-from flask import Blueprint, Response, current_app, jsonify
+from flask import Blueprint, current_app, jsonify
 from inventory_provider.tasks import worker
 from inventory_provider.routes import common
 
diff --git a/test/test_general_data_routes.py b/test/test_general_data_routes.py
index b11771ef035c47eb9d33ff4cb99b7bbc1f934cd7..fa8c385aa5866a4a77b583f43cb0c940831c676e 100644
--- a/test/test_general_data_routes.py
+++ b/test/test_general_data_routes.py
@@ -1,9 +1,6 @@
 import contextlib
 import json
 import jsonschema
-import pytest
-
-from inventory_provider.db import db
 
 DEFAULT_REQUEST_HEADERS = {
     "Content-type": "application/json",
diff --git a/test/test_opsdb_queries.py b/test/test_opsdb_queries.py
index 0584ed3e035c0bd72de37bbb5e98220fea05e432..e44e9597a11560908a711aad04755d2c0f8cf950 100644
--- a/test/test_opsdb_queries.py
+++ b/test/test_opsdb_queries.py
@@ -39,7 +39,6 @@ def connection(db_params):
 
 EQUIPMENT_LOCATION_METADATA = {
     "$schema": "http://json-schema.org/draft-07/schema#",
-    "type": "object",
 
     "definitions": {
         "pop-info": {
@@ -85,7 +84,6 @@ EQUIPMENT_LOCATION_METADATA = {
 
 CORIANT_PATH_METADATA = {
     "$schema": "http://json-schema.org/draft-07/schema#",
-    "type": "object",
 
     "definitions": {
         "pop-info": {
@@ -149,9 +147,9 @@ CORIANT_PATH_METADATA = {
 
 
 @pytest.mark.parametrize('equipment', [
-'mx1.cbg.uk.geant.net',
-'grv3.lon.uk.geant.net',
-'mx1.gen.ch.geant.net'
+    'mx1.cbg.uk.geant.net',
+    'grv3.lon.uk.geant.net',
+    'mx1.gen.ch.geant.net'
 ])
 def test_equipment_location(connection, equipment):
     circuit = opsdb.lookup_pop_info(connection, equipment)