Fixed schema bugs.
Added schema tests.