major fixes to main javascript and test javascript - all tests failing