Cleaning up code
 - Organizing into proper methods
 - Cleaning up JSON node creation
Fixing broken test