refactor some functions in testfiles to use composition, reducing api surface