How do I get a list of Drupal 7 active contexts for the current page/form in hook_form_alter?
The context name is the array key, not it's ->name field. See my answer here on how to programmatically check if a context is active. 

No need for foreach loop on $contexts on the 2nd and 3rd functions. Instead of loopoing on $contexts and printing for each context it's name field, you should simply print the array keys:

print_r (array_keys($contexts));