Remove dead code for cleaning up user API keys and permissions, add tests to make sure we didn't just break something.