Fix drop test databases when there is more than 1 active connection

The pice of code used is from pg.t, thanks @theory, great!