Extract common test helpers to dom module