working mainly on database abstraction, adding some tests