added require and tests
Lots of changes mostly around the JavaScript code. Tests added. Authentication corrected