factor out helpers from test/core