Refactor more code into subs in Testing.