Test the export function
Fix the export unicode handling, with tests.
Fixes #262