Added unit tests, added isClosed and guards to prevent calling read/write methods once closed