Added test for reader.. Rewrote reader and writer to be more flexible.