diff --git a/fillpdf.module b/fillpdf.module
index 47722aad019ae669be86ce28c6ea990f933a5048..4cb39468aef9076bb7686a0066a5279b1d744f10 100644
--- a/fillpdf.module
+++ b/fillpdf.module
@@ -263,53 +263,42 @@ function fillpdf_file_download_access_alter(&$grants, $file_item, $entity_type,
  *   The file url.
  */
 function fillpdf_pdf_link($fid, $nids = NULL, array $webform_arr = NULL, $sample = FALSE, $uc_order_ids = NULL, $uc_order_product_ids = NULL, $entity_ids = NULL) {
-  $nids_uri = $webforms_uri = $uc_orders_uri = $uc_order_products_uri = $entity_ids_uri = '';
+  $query = array('fid' => $fid);
 
-  // If an integer was provided, recast into a single-element array.
-  if ($nids && !is_array($nids)) {
-    $nids = array($nids);
-  }
-  if (is_array($nids) && count($nids)) {
-    $nids_uri = '&nids[]=' . implode('&nids[]=', $nids);
+  if (!empty($nids)) {
+    $nids = (array) $nids;
+    $query += count($nids) > 1 ? array('nids' => $nids) : array('nid' => reset($nids));
   }
 
   if (is_array($webform_arr) && count($webform_arr)) {
-    if (isset($webform_arr['nid'])) {
-      $webform_arr = array($webform_arr);
-    }
-    foreach ($webform_arr as $key => $webform) {
-      $webforms_uri .= "&webforms[{$key}][nid]={$webform['nid']}";
-      $webforms_uri .= isset($webform['sid']) ? "&webforms[{$key}][sid]={$webform['sid']}" : '';
-    }
+    $webform_arr = isset($webform_arr['nid'], $webform_arr['sid']) ? array($webform_arr) : $webform_arr;
+    $query += count($webform_arr) > 1 ? array('webforms' => $webform_arr) : array('webform' => reset($webform_arr));
   }
 
-  if (is_array($uc_order_ids) && count($uc_order_ids)) {
-    $uc_orders_uri = '&uc_order_ids[]=' . implode('&uc_order_ids[]=', $uc_order_ids);
-  }
-  elseif (isset($uc_order_ids)) {
-    $uc_orders_uri = "&uc_order_ids[]={$uc_order_ids}";
+  if (!empty($uc_order_ids)) {
+    $uc_order_ids = (array) $uc_order_ids;
+    $query += count($uc_order_ids) > 1 ? array('uc_order_ids' => $uc_order_ids) : array('uc_order_id' => reset($uc_order_ids));
   }
 
-  if (is_array($uc_order_product_ids) && count($uc_order_product_ids)) {
-    $uc_order_products_uri = '&uc_order_product_ids[]=' . implode('&uc_order_product_ids[]=', $uc_order_product_ids);
-  }
-  elseif (isset($uc_order_product_ids)) {
-    $uc_order_products_uri = "&uc_order_product_ids[]={$uc_order_product_ids}";
+  if (!empty($uc_order_product_ids)) {
+    $uc_order_product_ids = (array) $uc_order_product_ids;
+    $query += count($uc_order_product_ids) > 1 ? array('uc_order_product_ids' => $uc_order_product_ids) : array('uc_order_product_id' => reset($uc_order_product_ids));
   }
 
-  if (is_array($entity_ids) && count($entity_ids)) {
-    foreach ($entity_ids as $entity_id) {
-      $entity_ids_uri .= "&entity_ids[]={$entity_id}";
-    }
+  if (!empty($entity_ids)) {
+    $entity_ids = (array) $entity_ids;
+    $query += count($entity_ids) > 1 ? array('entity_ids' => $entity_ids) : array('entity_id' => reset($entity_ids));
   }
 
-  $sample = $sample ? '&sample=true' : '';
+  if ($sample) {
+    $query['sample'] = 'true';
+  }
 
-  // @todo: Refactor to use real url() syntax once tests in place
   $options = array(
+    'query' => $query,
     'absolute' => TRUE,
   );
-  return url('', $options) . "fillpdf?fid={$fid}{$nids_uri}{$webforms_uri}{$uc_orders_uri}{$uc_order_products_uri}{$entity_ids_uri}{$sample}";
+  return url('fillpdf', $options);
 }
 
 /**
diff --git a/tests/FillPdfEntityTestCase.test b/tests/FillPdfEntityTestCase.test
index a293c0efe15ab0301eb462bf2599d266ca828f16..ee810fdbf64a5f3e1a2549f5a485a226664a5138 100644
--- a/tests/FillPdfEntityTestCase.test
+++ b/tests/FillPdfEntityTestCase.test
@@ -97,15 +97,16 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Data provider for testBooleans().
+   * Data provider for testEntityLink().
    *
    * @return array
    *   Array of test cases.
    */
   public function dataProvider() {
-    $base_url = url('', array(
+    $base_url = url('fillpdf', array(
+      'query' => array('fid' => 1),
       'absolute' => TRUE,
-    )) . 'fillpdf?fid=1';
+    ));
 
     $test_cases = array();
 
@@ -115,7 +116,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'node' => array_slice($this->nodes, 0, 1),
       ),
-      $base_url . '&entity_ids[]=node:1',
+      $base_url . '&entity_id=node:1',
     );
 
     // Test case: multiple nodes.
@@ -124,7 +125,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'node' => $this->nodes,
       ),
-      $base_url . '&entity_ids[]=node:1&entity_ids[]=node:2&entity_ids[]=node:3',
+      $base_url . '&entity_ids[0]=node:1&entity_ids[1]=node:2&entity_ids[2]=node:3',
     ];
 
     // Test case: multiple nodes in reverse order.
@@ -133,7 +134,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'node' => array_reverse($this->nodes),
       ),
-      $base_url . '&entity_ids[]=node:3&entity_ids[]=node:2&entity_ids[]=node:1',
+      $base_url . '&entity_ids[0]=node:3&entity_ids[1]=node:2&entity_ids[2]=node:1',
     ];
 
     // Test case: single term.
@@ -142,7 +143,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'taxonomy_term' => array_slice($this->terms, 0, 1),
       ),
-      $base_url . '&entity_ids[]=taxonomy_term:11',
+      $base_url . '&entity_id=taxonomy_term:11',
     );
 
     // Test case: multiple terms.
@@ -151,7 +152,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'taxonomy_term' => $this->terms,
       ),
-      $base_url . '&entity_ids[]=taxonomy_term:11&entity_ids[]=taxonomy_term:12&entity_ids[]=taxonomy_term:13',
+      $base_url . '&entity_ids[0]=taxonomy_term:11&entity_ids[1]=taxonomy_term:12&entity_ids[2]=taxonomy_term:13',
     ];
 
     // Test case: single user.
@@ -160,7 +161,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'user' => array_slice($this->users, 0, 1),
       ),
-      $base_url . '&entity_ids[]=user:111',
+      $base_url . '&entity_id=user:111',
     );
 
     // Test case: multiple users.
@@ -169,7 +170,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
       array(
         'user' => $this->users,
       ),
-      $base_url . '&entity_ids[]=user:111&entity_ids[]=user:112&entity_ids[]=user:113',
+      $base_url . '&entity_ids[0]=user:111&entity_ids[1]=user:112&entity_ids[2]=user:113',
     ];
 
     // Test case: node, term, user.
@@ -180,7 +181,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
         'taxonomy_term' => array_slice($this->terms, 0, 1),
         'user' => array_slice($this->users, 0, 1),
       ),
-      $base_url . '&entity_ids[]=node:1&entity_ids[]=taxonomy_term:11&entity_ids[]=user:111',
+      $base_url . '&entity_ids[0]=node:1&entity_ids[1]=taxonomy_term:11&entity_ids[2]=user:111',
     );
 
     // Test case: user, term, multiple nodes.
@@ -191,7 +192,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
         'taxonomy_term' => array_slice($this->terms, 0, 1),
         'node' => $this->nodes,
       ),
-      $base_url . '&entity_ids[]=user:111&entity_ids[]=taxonomy_term:11&entity_ids[]=node:1&entity_ids[]=node:2&entity_ids[]=node:3',
+      $base_url . '&entity_ids[0]=user:111&entity_ids[1]=taxonomy_term:11&entity_ids[2]=node:1&entity_ids[3]=node:2&entity_ids[4]=node:3',
     );
 
     // Test case: user, multiple nodes in reverse order, term.
@@ -202,7 +203,7 @@ class FillPdfEntityTestCase extends DrupalWebTestCase {
         'node' => array_reverse($this->nodes),
         'taxonomy_term' => array_slice($this->terms, 0, 1),
       ),
-      $base_url . '&entity_ids[]=user:111&entity_ids[]=node:3&entity_ids[]=node:2&entity_ids[]=node:1&entity_ids[]=taxonomy_term:11',
+      $base_url . '&entity_ids[0]=user:111&entity_ids[1]=node:3&entity_ids[2]=node:2&entity_ids[3]=node:1&entity_ids[4]=taxonomy_term:11',
     );
 
     return $test_cases;
diff --git a/tests/FillPdfNodeTestCase.test b/tests/FillPdfNodeTestCase.test
index 811e2b0ada12c8833d8ce6ff8807b732cd7f0ff4..f717d64dd4c08393591cddcfe3c630f7b2497fb1 100644
--- a/tests/FillPdfNodeTestCase.test
+++ b/tests/FillPdfNodeTestCase.test
@@ -102,15 +102,16 @@ class FillPdfNodeTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Data provider for testNodeLink().
+   * Data provider for testNodeLink() and testLegacyNodeLink().
    *
    * @return array
    *   Array of test cases.
    */
   public function dataProvider() {
-    $base_url = url('', array(
+    $base_url = url('fillpdf', array(
+      'query' => array('fid' => 1),
       'absolute' => TRUE,
-    )) . 'fillpdf?fid=1';
+    ));
 
     $test_cases = array();
 
@@ -118,21 +119,21 @@ class FillPdfNodeTestCase extends DrupalWebTestCase {
     $test_cases[] = array(
       'Single node',
       array(reset($this->nodes)),
-      $base_url . '&nids[]=111',
+      $base_url . '&nid=111',
     );
 
     // Test case: multiple nodes.
     $test_cases[] = array(
       'Multiple nodes',
       $this->nodes,
-      $base_url . '&nids[]=111&nids[]=112&nids[]=113',
+      $base_url . '&nids[0]=111&nids[1]=112&nids[2]=113',
     );
 
     // Test case: multiple nodes in reverse order.
     $test_cases[] = array(
       'Multiple nodes (in reverse order)',
       array_reverse($this->nodes),
-      $base_url . '&nids[]=113&nids[]=112&nids[]=111',
+      $base_url . '&nids[0]=113&nids[1]=112&nids[2]=111',
     );
 
     return $test_cases;
diff --git a/tests/FillPdfWebformTestCase.test b/tests/FillPdfWebformTestCase.test
index ed321502ad4783a03a5a3db665121c46dcb54357..fd7b77e609ed8380edc2d1233e16071d83e81368 100644
--- a/tests/FillPdfWebformTestCase.test
+++ b/tests/FillPdfWebformTestCase.test
@@ -108,15 +108,16 @@ class FillPdfWebformTestCase extends DrupalWebTestCase {
   }
 
   /**
-   * Data provider for testBooleans().
+   * Data provider for testWebformLink() and testLegacyWebformLink().
    *
    * @return array
    *   Array of test cases.
    */
   public function dataProvider() {
-    $base_url = url('', array(
+    $base_url = url('fillpdf', array(
+      'query' => array('fid' => 1),
       'absolute' => TRUE,
-    )) . 'fillpdf?fid=1';
+    ));
 
     $test_cases = array();
 
@@ -124,7 +125,7 @@ class FillPdfWebformTestCase extends DrupalWebTestCase {
     $test_cases[] = array(
       'Single webform',
       array(reset($this->webforms)),
-      $base_url . '&webforms[0][nid]=111&webforms[0][sid]=211',
+      $base_url . '&webform[nid]=111&webform[sid]=211',
     );
 
     // Test case: multiple webforms.