Fix api keys being fetched from pg master.
Add test for api keys index. ref #302