Added testing to the script
Changed the script to work better on jenkins