added some unit tests, unreliable close implemented