Add facroties.rb anf fix test script