improved json_attributes printing code smell
Added tests for --json-attributes option