Test api_key login (and fix a bug).