refactor tests

workaround build callback being called multiple times on errors