Fixing the query-key in the new admin tool

I made the fix to the old tool incorrectly. Ported the code to the new
tool with no modification. Talked to Xu and merging this directly

Also added a minor fix to the unit tests which fails sometimes because
of error. Added some retries and ignoring the failure.