Add some test if stream is opened and other minor fixes