Fixes for unit-tests, old tests did not remove instances, did not wait

for session to close, etc.