PostgreSQL tests

I started to add tests for PostgreSQL and already fixed some issues. Though, some tests still fail. From my point of view, it is not safe to use PostgreSQL at the moment.