Fixed utils.get_variables to deal more robustly with context contents th...

...at don't support .keys().