Add PSN API for SiteDB, fix unit tests for real data and emulator

One new API and a lot of cleanup to make unit tests pass against the emulator and the real SiteDB.