tests speedup, code cleanup