tests plus a big refactor of the connection constructor