Refactoring to move the AST implementation details out of tests