Added tests for write operation and some repairs