Statistics: more granular error messages

error messages are logged and also sent to ExtJS
clearer logic/flow
variable ID validation

fix in roda.R to output valid JSON (for 2 variables)