fixed json encoder and tests