refactor format function
specific tests for every formatrule, fix format fun