made jquery local
refactored and added tests: