refactor check functions in tests