Fixed problems with JSON. Everything seems to be working
Added tests