Unit tests for SELECT JSON, related fix