Added unit tests to test reading of corrupted data and other minor edits