simplify utils.py, add unittests (incomplete)