extract format_plugin and add tests for it