syslog_ng: Rearrange methods between syslog-ng state and execution modul...

...e.

It also adds the missing unit tests and now is using buffer.write() instead of print statements.