test: move common functions into test lib