Factored out _crop method for better testability in unit tests