Tests and DB management improvements

Corrected tests,
made a function for DB creation,
db is now configurable via environment variable DATABASE_URL.