Fix failing test, and add stack overflow fix