Back porting wyclif's changes for including tests to improve the logic …
for selecting the preferred name - TRUNK-3232