Move AST implementation details out of tests