Fix insecure public/secret key verification

This pull request includes:

1) a rewrite of the router tests that factors common code inside adhoc methods.
2) a change in how the redis cache is handled by the tests: by default, it is now flushed at the beginning of every router test.
3) a fix to properly check the public/secret key pair posted to the backend, even when the project id is correct.