Add do_export and tests