Add PK check testcases and fix bugs found using them