Restructure JS and Add Test Coverage

IN PROGRESS.

See #55.