db is now called peristence, changed functions to support different databases, used defdb, added tests