Added tests for struct reader and writer. Fixed many bugs with them. Fixes issue #7.