While it is generally understood that unit testing is the activity of running tests to ensure that a unit is upholding its contract, the concept of a unit is often left undefined. In short, a unit is a subset of code which can be compiled on its own. For example, a framework or library is a unit. However, units may be comprised of other units. Internal types may form their own units, which are depended on by the public interface of the library. Any type with functionality (methods) may form its own unit.
One of the fundamental differences between unit testing and other forms of software testing is the specificity of the tests. Each test covers a single entry point into the public interface, and does not endeavor to test how pieces interact. Any such interactions are treated as implementation details. The unit test ensures that the contract of the entry point is met. The how is unimportant.