moved some code into TestCircus for reusing