Documentation, testing, refactoring

Added YUIDoc tags, more jasmine tests and refactored scripts.js to
improve readability.
modified tests

rewrote some jasmine tests to reflect refactored changes in scripts.js