Check for 'nil?' before 'empty?'

This fixes test breakage on Ruby 1.9.3.