Fixed several TODOs, and adapted and restored the old unit tests.