Be more lenient with trim()

Allowing for null and undefined values passed to trim() to return empty string.

I'm not sure if you would rather deal with this in the functions calling trim() but this will at least allow some flexibility handling attributes that may be null or contain a string.