Check for 'nil?' before 'empty?'

This fixes test breakage on Ruby 1.9.3.
Merge pull request #1 from jvirtanen/fixes/nil-or-empty

Check for 'nil?' before 'empty?'