Improved test case for grouping DOM nodes