More refactoring to remove duplicate code for scope key checks.

Signed-off-by: Jerome Doby <XaeroDegreaz@gmail.com>