fix hung sessions
fix table locks during testing on postgresql
refactor tests, run in ful isolation