Refactor test util functions as methods.