Added multi PKs, tests and refactoring