Improving the logic to detect the need for restart.

This avoids a lot of unnecessary restarts
Adding groovy as a dependency
Adding groovy console support to assist the test development
adding a mechanism to export local variables
Use the same set of cookies so that it sees the same thing Selenium sees