Improve reference data checks against same data.
Make it easier to perform multiple checks against the same reference
data using the TestReferenceChecker. nextSearchNode_ was always NULL
when the reference data was getting written, which caused every check to
write a new reference data entry. Now, the search is also performed as
part of writing the reference data, so that only the first check with a
particular id creates an entry, and subsequent checks perform the check
against this entry.
The analysis data tests were depending on duplicate ids behaving
differently, so changed them to also use the same pattern as elsewhere
for repeating elements, i.e., NULL ids.
Related to #651.
Change-Id: Icc0d1d68a0846bbdcc9639933e8060e56cb4b30e