fixed reading compressed data bug, added tests