Postgres implementation with tests