schema: centralize mapper logic; improve testing