Functions and tests to detect table orientation.