Refactored currency formatting helper to be easier to understand and fixed a rounding bug (thanks @serrynaimo for the report)