Fix using a variable which is not defined

There is a variable which is not defined but used, we should define it
before using. Add a test for get_resource_manager_extra_kwargs_hook
function, and change the exception to a more detail instead broad
'Exception'.

Change-Id: I7a798dad55a65f06ebbe175925a00028940bb168
Merge "Fix using a variable which is not defined"