Add tests for Client Credentials Flow endpoint and middleware. Fix bugs.