Issue #393 Adding missing fire event for onClose with file rendering

Issue #393 - Adding more tests and refactoring duplicated file transmitter code
Cool, if you open another issue we can handle it there.