Changed the formatters to functions returning formatting functions.

Added better handling of empty (nulls/undefined/NaN) values.
Added tests checking for empty values.