diff --git a/mutalyzer/db/queries.py b/mutalyzer/db/queries.py
index ab4e814e5718737c46fac971d066b65e6c5206cc..d457b60c1d60f9774991ed703528c2b15cb34a8c 100644
--- a/mutalyzer/db/queries.py
+++ b/mutalyzer/db/queries.py
@@ -87,17 +87,13 @@ def get_transcript_protein_link(accession, reverse=False):
         # Lookup by protein accession instead of transcript accession.
         query_column, other_column = other_column, query_column
 
-    return TranscriptProteinLink.query \
-        .filter_by(transcript_accession=accession) \
-        .filter(
-            query_column == accession,
-            or_(
-                and_(other_column.isnot(None),
-                     TranscriptProteinLink.added >= link_datetime),
-                and_(other_column.is_(None),
-                     TranscriptProteinLink.added >= negative_link_datetime))
-        ) \
-        .first()
+    return TranscriptProteinLink.query.filter(
+        query_column == accession,
+        or_(and_(other_column.isnot(None),
+                 TranscriptProteinLink.added >= link_datetime),
+            and_(other_column.is_(None),
+                 TranscriptProteinLink.added >= negative_link_datetime))
+    ).first()
 
 
 def update_transcript_protein_link(transcript_accession=None,
diff --git a/tests/test_db_queries.py b/tests/test_db_queries.py
new file mode 100644
index 0000000000000000000000000000000000000000..2f4b2d5e73d639d537981536af9c252d37a0d0bd
--- /dev/null
+++ b/tests/test_db_queries.py
@@ -0,0 +1,67 @@
+"""
+Tests for the mutalyzer.db.queries module.
+"""
+
+
+from __future__ import unicode_literals
+
+#import logging; logging.basicConfig()
+
+from mutalyzer.db import queries
+
+from fixtures import database, cache
+from utils import MutalyzerTest
+from utils import fix
+
+
+class TestMutator(MutalyzerTest):
+    """
+    Test the queries module.
+    """
+    fixtures = (database, )
+
+    def setup(self):
+        super(TestMutator, self).setup()
+
+    @fix(cache('MARK1'))
+    def test_get_transcript_protein_link(self):
+        """
+        Query a transcript-protein link by transcript.
+        """
+        link = queries.get_transcript_protein_link('NM_018650')
+        assert link.transcript_accession == 'NM_018650'
+        assert link.protein_accession == 'NP_061120'
+
+    @fix(cache('MARK1'))
+    def test_get_transcript_protein_link_negative(self):
+        """
+        Query a negative transcript-protein link by transcript.
+        """
+        link = queries.get_transcript_protein_link('XM_005273133')
+        assert link.transcript_accession == 'XM_005273133'
+        assert link.protein_accession is None
+
+    @fix(cache('MARK1'))
+    def test_get_transcript_protein_link_missing(self):
+        """
+        Query a missing transcript-protein link by transcript.
+        """
+        link = queries.get_transcript_protein_link('NM_123456')
+        assert link is None
+
+    @fix(cache('MARK1'))
+    def test_get_transcript_protein_link_reverse(self):
+        """
+        Query a transcript-protein link by protein.
+        """
+        link = queries.get_transcript_protein_link('NP_061120', reverse=True)
+        assert link.transcript_accession == 'NM_018650'
+        assert link.protein_accession == 'NP_061120'
+
+    @fix(cache('MARK1'))
+    def test_get_transcript_protein_link_reverse_missing(self):
+        """
+        Query a missing transcript-protein link by protein.
+        """
+        link = queries.get_transcript_protein_link('NP_123456')
+        assert link is None