Extract test utils
Fix groovy output redirection