CSPACE-6273; In custom function, move utility functions out of main Puppet function. Use FileTest rather than File, use backticks for system call.