fixed trim to trim values by padding char before cast

fixed unit tests and fixed trim to trim values by padding char before cast in the sprintf value formatter