polish the json generation and add better test case