refactor main.js to be able to test patch separately of view