Fixed --json, and added test script