Fix initialization of viewportTransform array

Add unit tests
JSDoc tweaks

Closes #1494
About time to add those! Thanks @Kienz : )