diff --git a/ng_lightbox.info b/ng_lightbox.info
index 2012b09..6310e45 100644
--- a/ng_lightbox.info
+++ b/ng_lightbox.info
@@ -4,4 +4,4 @@ core = 7.x
 package = NG
 configure = admin/config/media/ng-lightbox
 
-files[] = ng_lightbox.test
+files[] = tests/ng_lightbox.test
diff --git a/ng_lightbox.module b/ng_lightbox.module
index dcfd2a1..55c8653 100644
--- a/ng_lightbox.module
+++ b/ng_lightbox.module
@@ -155,15 +155,24 @@ function ng_lightbox_path_callback() {
   $lightbox_path = $_POST['ng_lightbox_path'];
   global $base_path;
 
-  // Parse out the path parts intor a normalised Drupal path.
+  // Parse out the path parts and query string, taking into account clean urls
+  // and making sure to preserve query params for the next request.
   $url_parts = parse_url($lightbox_path);
+  if (isset($url_parts['query'])) {
+    parse_str($url_parts['query'], $query);
+    $_GET = $query;
+  }
+  // If clean urls are enabled, grab the path.
   if (variable_get('clean_url', 0)) {
     $path = substr($url_parts['path'], strlen($base_path));
   }
   else {
-    // Remove q= from the query string to get the path.
-    $path = substr($url_parts['query'], 2);
+    // Clean urls are disabled so we're using the "q" param. We know we have
+    // $query because clean_urls are off, otherwise something went very wrong.
+    $path = $query['q'];
   }
+
+  // Normalize the path for Drupal.
   $path = drupal_get_normal_path($path) ?: $path;
 
   // We override these globals to make current_path() work and so that any
diff --git a/tests/modules/ng_lightbox_test/ng_lightbox_test.info b/tests/modules/ng_lightbox_test/ng_lightbox_test.info
new file mode 100644
index 0000000..6ea30c4
--- /dev/null
+++ b/tests/modules/ng_lightbox_test/ng_lightbox_test.info
@@ -0,0 +1,5 @@
+name = NG Lightbox Test
+description = Test module
+core = 7.x
+package = NG
+hidden = true
diff --git a/tests/modules/ng_lightbox_test/ng_lightbox_test.module b/tests/modules/ng_lightbox_test/ng_lightbox_test.module
new file mode 100644
index 0000000..d9272af
--- /dev/null
+++ b/tests/modules/ng_lightbox_test/ng_lightbox_test.module
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * @file
+ * Test module.
+ */
+
+/**
+ * Implements hook_menu().
+ */
+function ng_lightbox_test_menu() {
+  return array(
+    'ng-lightbox-test' => array(
+      'page callback' => 'ng_lightbox_test_page',
+      'title' => 'Test page',
+      'access callback' => TRUE,
+    ),
+  );
+}
+
+function ng_lightbox_test_page() {
+  return print_r($_GET, TRUE);
+}
diff --git a/ng_lightbox.test b/tests/ng_lightbox.test
similarity index 93%
rename from ng_lightbox.test
rename to tests/ng_lightbox.test
index 276d091..e03fbc3 100644
--- a/ng_lightbox.test
+++ b/tests/ng_lightbox.test
@@ -23,7 +23,7 @@ class NgLightboxTest extends DrupalWebTestCase {
    */
   public function setUp() {
     variable_set('clean_url', TRUE);
-    parent::setUp(array('ng_lightbox'));
+    parent::setUp(array('ng_lightbox', 'ng_lightbox_test'));
   }
 
   /**
@@ -81,6 +81,13 @@ class NgLightboxTest extends DrupalWebTestCase {
     $commands = $this->simplePostAJAX('ng-lightbox', array('ng_lightbox_path' => $node_path . '/edit'));
     $this->assertContains('action="' . $base_path . 'node/1/edit"', $commands[1]['data'], 'Form has a valid form action.');
     $this->assertContains('page_node_form', $commands[1]['data'], 'Node edit form returned.');
+
+    // Ensure the query params are preserved to the lightbox request.
+    $random_1 = $this->randomName();
+    $random_2 = $this->randomName();
+    $commands = $this->simplePostAJAX('ng-lightbox', array('ng_lightbox_path' => $base_path . "ng-lightbox-test?p1=$random_1&p2=$random_2"));
+    $this->assertContains('[p1] => ' . $random_1, $commands[1]['data'], 'Query params are preserved.');
+    $this->assertContains('[p2] => ' . $random_2, $commands[1]['data'], 'Query params are preserved.');
   }
 
   /**
