Fix bugs, make test case a bit more realistic.