Refactor escript parts
Fix broken unit tests