Add label formatting functionality and tests