cleanup + tests

Hi rscada-team,

i separated the code, ported a few things to python 3 and added automated tests.

Cheers,
tpltnt