[Emulink] Fixed issue in creation per_function, improved state_machine.js structure