Fixing some stuff and adding more tests.