diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index da7c265..f862fbd 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -434,7 +434,7 @@ function simpletest_log_read($test_id, $prefix, $test_class, $during_test = FALS
  *     );
  *   @endcode
  */
-function simpletest_test_get_all() {
+function simpletest_test_get_all($module = NULL) {
   $groups = &drupal_static(__FUNCTION__);
 
   if (!$groups) {
@@ -453,6 +453,11 @@ function simpletest_test_get_all() {
       $module_data = system_rebuild_module_data();
       $all_data = $module_data + system_rebuild_theme_data();
       $all_data += drupal_system_listing('/\.profile$/', 'profiles', 'name');
+      if (isset($module)) {
+        $all_data = array(
+          $module => $all_data[$module],
+        );
+      }
       foreach ($all_data as $name => $data) {
         // Build directory in which the test files would reside.
         $tests_dir = DRUPAL_ROOT . '/' . dirname($data->uri) . '/lib/Drupal/' . $name . '/Tests';
@@ -727,12 +732,17 @@ function simpletest_library_info() {
  * @param bool $name_only
  *  If TRUE, returns a flat array of class names only.
  */
-function simpletest_phpunit_get_available_tests() {
+function simpletest_phpunit_get_available_tests($module = NULL) {
   // Try to load the class names array from cache.
-  if ($cache = \Drupal::cache()->get('simpletest_phpunit')) {
+  $cid = 'simpletest_phpunit:' . $module;
+  if ($cache = \Drupal::cache()->get($cid)) {
     $test_classes = $cache->data;
   }
   else {
+    if ($module) {
+      $prefix = 'Drupal\\' . $module . '\\';
+      $n = strlen($prefix);
+    }
     // If there was no cached data available we have to find the tests.
     // Load the PHPUnit configuration file, which tells us where to find the
     // tests.
@@ -750,13 +760,13 @@ function simpletest_phpunit_get_available_tests() {
       }
 
       $name = get_class($test);
-      if (!array_key_exists($name, $test_classes)) {
+      if (!array_key_exists($name, $test_classes) && (!$module || substr($name, 0, $n) == $prefix)) {
         $test_classes[$name] = $test->getInfo();
       }
     }
 
     // Since we have recalculated, we now need to store the new data into cache.
-    \Drupal::cache()->set('simpletest_phpunit', $test_classes);
+    \Drupal::cache()->set($cid, $test_classes);
   }
 
   return $test_classes;
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 58f45ae..28a5376 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -201,7 +201,7 @@ function simpletest_script_parse_args() {
     'php' => '',
     'concurrency' => 1,
     'all' => FALSE,
-    'module' => FALSE,
+    'module' => NULL,
     'class' => FALSE,
     'file' => FALSE,
     'color' => FALSE,
@@ -341,9 +341,9 @@ function simpletest_script_init($server_software) {
  *     );
  *   @endcode
  */
-function simpletest_script_get_all_tests() {
-  $tests = simpletest_test_get_all();
-  $tests['PHPUnit'] = simpletest_phpunit_get_available_tests();
+function simpletest_script_get_all_tests($module = NULL) {
+  $tests = simpletest_test_get_all($module);
+  $tests['PHPUnit'] = simpletest_phpunit_get_available_tests($module);
   return $tests;
 }
 
@@ -619,8 +619,8 @@ function simpletest_script_get_test_list() {
   global $args;
 
   $test_list = array();
-  if ($args['all']) {
-    $groups = simpletest_script_get_all_tests();
+  if ($args['all'] || $args['module']) {
+    $groups = simpletest_script_get_all_tests($args['module']);
     $all_tests = array();
     foreach ($groups as $group => $tests) {
       $all_tests = array_merge($all_tests, array_keys($tests));
@@ -633,20 +633,6 @@ function simpletest_script_get_test_list() {
         $test_list[] = $class_name;
       }
     }
-    elseif ($args['module']) {
-      $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0);
-      foreach ($args['test_names'] as $module) {
-        // PSR-0 only.
-        $dir = dirname($modules[$module]->uri) . "/lib/Drupal/$module/Tests";
-        $files = file_scan_directory($dir, '@\.php$@', array(
-          'key' => 'name',
-          'recurse' => TRUE,
-        ));
-        foreach ($files as $test => $file) {
-          $test_list[] = "Drupal\\$module\\Tests\\$test";
-        }
-      }
-    }
     elseif ($args['file']) {
       // Extract test case class names from specified files.
       foreach ($args['test_names'] as $file) {
