functest.js now returns a non-zero exit code when there's a failure, replaced writeFileSync with writeFile in an attempt improve performance