Set title from first heading
Guard call to window.history.replaceState in case state object is too large.
Tweak query in tests to only match primary cell lines.