Changes to JSON string encodeing and added test loop