Fixes scopes missing using auth code

This commit fixes the issue and adds a new test.