separated code for opt tests