Moved some functions in the man test code to functions.