Fixed test to make sure that valid value is passed to ToJSON
[#84359170]
Use constructor functions

[#84359170]

Signed-off-by: Atul Kshirsagar <atul.kshirsagar@gmail.com>