Changed output of empty results from an empty JSON object back to an
empty string. Also some minor refactoring to make some conditionals more
clear and adjusting some test cases.