Refactored code for consistancy.

Also moved the database test to the submit activity, where it will end up
being used.