Fix typo with null check in getInstance.

The behavior was broken in 38698a8.  This should fix it and the test
should ensure it continues to work.