Extract user write scram to module.

Extract the user write scram to a module for testing.

See #375.