externalize stop conditions
unittests