Rewrite for mappings and related tests (fix #2)