applied a fix by Kenneth Kroenlein to support named primary key (RT 95511), and added some tests