diff --git a/D7-core-selenium.patch b/D7-core-selenium.patch
old mode 100644
new mode 100755
index e3bccb5..5e0ff76
--- a/D7-core-selenium.patch
+++ b/D7-core-selenium.patch
@@ -2,80 +2,17 @@ diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
 index bbddde2..c917715 100644
 --- a/includes/bootstrap.inc
 +++ b/includes/bootstrap.inc
-@@ -2190,9 +2190,9 @@ function drupal_valid_test_ua() {
+@@ -2469,9 +2469,10 @@
      // The file properties add more entropy not easily accessible to others.
      $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__);
      $time_diff = REQUEST_TIME - $time;
 -    // Since we are making a local request a 5 second time window is allowed,
-+    // Since we are making a local request a 600 second time window is allowed,
-     // and the HMAC must match.
+-    // and the HMAC must match.
 -    if ($time_diff >= 0 && $time_diff <= 5 && $hmac == drupal_hmac_base64($check_string, $key)) {
-+    if ($time_diff >= 0 && $time_diff <= 600 && $hmac == drupal_hmac_base64($check_string, $key)) {
++    // Since we are making a local request a 5 seconds time window is allowed,
++    // and the HMAC must match. However, for selenium it's usually not enough to
++    // pull-up a browser window and render a page, so we set 500 seconds window.
++    if ($time_diff >= 0 && $time_diff <= 500 && $hmac == drupal_hmac_base64($check_string, $key)) {
        $test_prefix = $prefix;
        return $test_prefix;
      }
-diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
-index b60c682..0c67d7b 100644
---- a/modules/simpletest/drupal_web_test_case.php
-+++ b/modules/simpletest/drupal_web_test_case.php
-@@ -45,6 +45,11 @@ abstract class DrupalTestCase {
-   protected $timeLimit = 500;
- 
-   /**
-+   * Browser that runs test.
-+   */
-+  protected $browser;
-+
-+  /**
-    * Current results of this test case.
-    *
-    * @var Array
-@@ -464,6 +469,12 @@ abstract class DrupalTestCase {
-     foreach ($class_methods as $method) {
-       // If the current method starts with "test", run it - it's a test.
-       if (strtolower(substr($method, 0, 4)) == 'test') {
-+        // Get information about test case.
-+        $info = $this->getInfo();
-+        // If no browsers are set we use internal.
-+        if (!isset($info['browsers'])) {
-+          $info['browsers'] = array('internal');
-+        }
-         // Insert a fail record. This will be deleted on completion to ensure
-         // that testing completed.
-         $method_info = new ReflectionMethod($class, $method);
-@@ -472,18 +483,24 @@ abstract class DrupalTestCase {
-           'line' => $method_info->getStartLine(),
-           'function' => $class . '->' . $method . '()',
-         );
--        $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
--        $this->setUp();
--        try {
--          $this->$method();
--          // Finish up.
--        }
--        catch (Exception $e) {
--          $this->exceptionHandler($e);
-+
-+        // Run test in each browser.
-+        foreach ($info['browsers'] as $browser) {
-+          $this->browser = $browser;
-+
-+          $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
-+          try {
-+            $this->setUp();
-+            $this->$method();
-+            // Finish up.
-+          }
-+          catch (Exception $e) {
-+            $this->exceptionHandler($e);
-+          }
-+          $this->tearDown();
-+          // Remove the completion check record.
-+          DrupalTestCase::deleteAssert($completion_check_id);
-         }
--        $this->tearDown();
--        // Remove the completion check record.
--        DrupalTestCase::deleteAssert($completion_check_id);
-       }
-     }
-     // Clear out the error messages and restore error handler.
diff --git a/drupal_selenium_web_test_case.php b/drupal_selenium_web_test_case.php
old mode 100644
new mode 100755
index 5cad4c0..bea28b8
--- a/drupal_selenium_web_test_case.php
+++ b/drupal_selenium_web_test_case.php
@@ -21,6 +21,11 @@ class DrupalSeleniumWebTestCase extends DrupalWebTestCase {
   protected $driver;
 
   /**
+   * Browser that runs test.
+   */
+  protected $browser;
+
+  /**
    * Allowed driver types.
    */
   protected $allowed_browsers = array('firefox', 'chrome');
@@ -39,6 +44,82 @@ class DrupalSeleniumWebTestCase extends DrupalWebTestCase {
   }
 
   /**
+   * Run all tests in this class.
+   *
+   * Regardless of whether $methods are passed or not, only method names
+   * starting with "test" are executed.
+   *
+   * @param $methods
+   *   (optional) A list of method names in the test case class to run; e.g.,
+   *   array('testFoo', 'testBar'). By default, all methods of the class are
+   *   taken into account, but it can be useful to only run a few selected test
+   *   methods during debugging.
+   */
+  public function run(array $methods = array()) {
+    // Initialize verbose debugging.
+    simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), get_class($this));
+
+    // HTTP auth settings (<username>:<password>) for the simpletest browser
+    // when sending requests to the test site.
+    $this->httpauth_method = variable_get('simpletest_httpauth_method', CURLAUTH_BASIC);
+    $username = variable_get('simpletest_httpauth_username', NULL);
+    $password = variable_get('simpletest_httpauth_password', NULL);
+    if ($username && $password) {
+      $this->httpauth_credentials = $username . ':' . $password;
+    }
+
+    set_error_handler(array($this, 'errorHandler'));
+    $class = get_class($this);
+    // Iterate through all the methods in this class, unless a specific list of
+    // methods to run was passed.
+    $class_methods = get_class_methods($class);
+    if ($methods) {
+      $class_methods = array_intersect($class_methods, $methods);
+    }
+    foreach ($class_methods as $method) {
+      // If the current method starts with "test", run it - it's a test.
+      if (strtolower(substr($method, 0, 4)) == 'test') {
+        // Get information about test case.
+        $info = $this->getInfo();
+        // If no browsers are set we use internal.
+        if (!isset($info['browsers'])) {
+           $info['browsers'] = array('internal');
+        }
+
+        // Insert a fail record. This will be deleted on completion to ensure
+        // that testing completed.
+        $method_info = new ReflectionMethod($class, $method);
+        $caller = array(
+          'file' => $method_info->getFileName(),
+          'line' => $method_info->getStartLine(),
+          'function' => $class . '->' . $method . '()',
+        );
+
+        // Run test in each browser.
+        foreach ($info['browsers'] as $browser) {
+          $this->browser = $browser;
+
+          $completion_check_id = DrupalTestCase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller);
+          try {
+            $this->setUp();
+            $this->$method();
+            // Finish up.
+          }
+          catch (Exception $e) {
+            $this->exceptionHandler($e);
+          }
+          $this->tearDown();
+          // Remove the completion check record.
+          DrupalTestCase::deleteAssert($completion_check_id);
+        }
+      }
+    }
+    // Clear out the error messages and restore error handler.
+    drupal_get_messages();
+    restore_error_handler();
+  }
+
+  /**
    * Init driver of specified type.
    *
    * @param string $browser
@@ -46,11 +127,27 @@ class DrupalSeleniumWebTestCase extends DrupalWebTestCase {
    * @return object
    */
   protected function seleniumDriver($browser) {
+    // We need to define user agent only for local tests, which manipulate database.
+    // For remote tests it's not necessary.
+    if (isset($this->databasePrefix)) {
+      $test_id = $GLOBALS['drupal_test_info']['test_run_id'];
+      if (preg_match('/simpletest\d+/', $test_id, $matches)) {
+        $user_agent = drupal_generate_test_ua($matches[0]);
+      }
+      else {
+        throw new Exception('Test is not ready to init connection to Webdriver (no database prefix)');
+      }
+    }
+    else {
+      $user_agent = '';
+      $test_id = $this->testId;
+    }
+
     switch ($browser) {
       case 'firefox':
-        return new SeleniumFirefoxDriver();
+        return new SeleniumFirefoxDriver($user_agent, $test_id);
       case 'chrome':
-        return new SeleniumChromeDriver();
+        return new SeleniumChromeDriver($user_agent, $test_id);
     }
   }
 
@@ -2098,18 +2195,10 @@ class SeleniumWebElement {
  * Class of the connection to Firefox.
  */
 class SeleniumFirefoxDriver extends SeleniumWebDriver {
-  function __construct() {
-    $database_prefix = $GLOBALS['drupal_test_info']['test_run_id'];
-    if (preg_match('/simpletest\d+/', $database_prefix, $matches)) {
-      $user_agent = drupal_generate_test_ua($matches[0]);
-    }
-    else {
-      throw new Exception('Test is not ready to init connection to Webdriver (no database prefix)');
-    }
-
+  function __construct($user_agent, $test_id) {
     $temporary_path = file_directory_temp();
     file_prepare_directory($temporary_path);
-    $zip_file_path = $temporary_path . '/' . $database_prefix . '_firefox_profile.zip';
+    $zip_file_path = $temporary_path . '/' . $test_id . '_firefox_profile.zip';
 
     // Generate Firefox profile.
     $zip = new ZipArchive;
@@ -2163,15 +2252,7 @@ class SeleniumFirefoxDriver extends SeleniumWebDriver {
  */
 class SeleniumChromeDriver extends SeleniumWebDriver {
 
-  function __construct() {
-    $database_prefix = $GLOBALS['drupal_test_info']['test_run_id'];
-    if (preg_match('/simpletest\d+/', $database_prefix, $matches)) {
-      $user_agent = drupal_generate_test_ua($matches[0]);
-    }
-    else {
-      throw new Exception('Test is not ready to init connection to Webdriver (no database prefix)');
-    }
-
+  function __construct($user_agent, $testCase) {
     $user_agent_string = '--user-agent=' . $user_agent;
 
     // Start browser.
