fixes #292 - adds postgres tests and fixes postgres issues