NEW: Adding tests and code tidyup
NEW: Adding a option to run a batch job to the front end