Test messages before treating them as JSON