Refactoring: move implementation details to JSContext

NDArray is refactored to be a context-independent wrapper