Bug fix, unit tests and new feature addition.

There are some some bug fix and some unit tests to prevent this bugs to happen again.
Also there is a new feature, Read Class and Write Class.