Changed R script and updated output test validate function