Fix initialization of viewportTransform array

Add unit tests
JSDoc tweaks

Closes #1494