handle json decoding errors better; test for json decoding errors