What's the best way to use helper functions for tests?

I'm about to add a few tests to my app. There are some repeating things and instead of copy&pasting it I'd prefer to only write it once. But these helper functions only need to be present for tests. If I annotate them with (:test) then the system things they are tests and they fail. If I don't annotate them then they're included in the release build. What's the best practice?

// I don't want this to be compiled into the release, it's only used in the tests
function newFoo() as Foo {
    return new Foo(1,2,3);
}

(:test)
function test1(logger as Logger) as Boolean {
    var foo = newFoo();
    //...
    return ...;
}

(:test)
function test2(logger as Logger) as Boolean {
    var foo = newFoo();
    //...
    return ...;
}