Changed all js files to IIFE and refactor tests