Improved test to detect primary key bug