Completely revise tests + fix stack overflow and other test failures.