Patch for test

This patches improve tests.
These are not necessary soon but would be needed when we bump core to later versions.
This new file contains copied code from DuplicatesUtil.java, so the copyright needs to follow as well.