Testability refactor of js for flag symbols. Also wrapped functions with the flag_gen object to avoid polluting the global scope.