Improved checking for values with units in Unparser

Check that the value actually has units before attempting a conversion. This was exposing a bug in the units gem that caused a crash when trying to convert a value without units. Even with that bug fixed, this would have caused undesired conversions because unit-less numbers shouldn't be converted on output.

Also, rely on duck-typing instead of checking for a particular class.