Implement TableExists and added a lot of unit tests.