Use with statement
Put random stuff generators to tests.utils
Enforce some coding guidelines
Simplify database model