Reflect refactoring of wsend on install script

...as they share a great amount of code, I just refactor all code for a better maintability