Complete Unit test for toJSON and fromJSON methods