datum writer for primitives, tests, refactor