factor out copy and paste from tests