fix(javascript): Javascript errors at runtime after refactoring

Functions out of the scop should have the beneficiairesService passed as parameter.