Refactoring of tester.php

Because tester.php becomes spagetti ~~western~~ code, the Good, the Bad and the Ugly