Implemented toJSON and added tests
travisplexer: pr-454-osx travis ci test