added postgres backend, refactored tests & errors