fix NaN gauge json serialization
add test for exceptions in gauge functions