Fixes bug in tests.php where lock file would not be deleted.

The lock file was being created, and then the parameters were being validated for errors. If errors were found, the script might exit and leave the lock file there. Now it waits until input is validated before creating the lock file.