Fix dollar and percent to return zero length output on zero length input

Actual change in dollar_format and percent_format which carry
over to dollar and percent.

Added tests which cover all formatters and format generators to
make sure zero length input gives zero length output.

Fixes #34