Formatting functions and tests