small refactor of currentGalleryRef
TS fixes
unit test fixes
fixing unit tests