Extract JS stuff into own class

Add some extra integration (which appears to be
quicker than the unit tests)