In Forrest & Barr v Henderson & Co. 8 M. 187, 193 the Lord Inglis said:
I hold it to be part of our law on this subject that, even where parties stipulate that a sum of this kind shall not be regarded as a penalty, but shall be taken as an estimate and ascertainment of the amount of damage to be sustained in a certain event, equity will interfere to prevent the claim being maintained to exorbitant and unconscionable amount. But, of course, the question whether it is exorbitant or unconscionable is to be considered with reference to the point of time at which the stipulation is made between the parties.
In Dunlop Pneumatic Tyre Co Ltd v New Garage and Motor Co Ltd  AC 79 at 86-87, per Lord Dunedin:
1. Though the parties to a contract who use the words "penalty" or "liquidated damages may prima facie be supposed to mean what they say, yet the expression used is not conclusive. The Court must find out whether the payment stipulated is in truth a penalty or liquidated damages. This doctrine may be said to be found passim in nearly every case.
2. The essence of a penalty is a payment of money stipulated as in terrorem of offending party; the essence of liquidated damages is a genuine covenanted pre-estimate of damage (Clydebank Engineering and Shipbuilding Co. v. Don Jose Ramos Yzquierdo y Castaneda  AC 6).
3. The question whether a sum stipulated is penalty or liquidated damages is a question of construction to be decided upon the terms and inherent circumstances of each particular contract, judged of as at the time of the making of the contract, not as at the time of the breach (Public Works Commissioner v Hills  AC 368 and Webster v Bosanquet  AC 394).
4. To assist this task of construction various tests have been suggested, which applicable to the case under consideration may prove helpful, or even conclusive. Such tests are:
(a) It will be held to be penalty if the sum stipulated for is extravagant and unconscionable amount in comparison with the greatest loss that could conceivably be proved to have followed from the breach. (Illustration given by Lord Halsbury in Clydebank Case.  A. C. 6.)
(b) It will be held to be a penalty if the breach consists only in not paying a sum of money, and the sum stipulated is a sum greater than the sum which ought to have been paid(Kemble v Farren 6 Bing. 141). This though one of the most ancient instances is truly a corollary to the last test. …
(c) There is a presumption (but no more) that it is penalty when "a single lump sum is made payable by way of compensation, on the occurrence of one or more or all of several events, some of which may occasion serious and others but trifling damage" (Lord Watson in Lord Elphinstone v. Monkland Iron and Coal Co. 11 App. Cas. 332).
On the other hand:
(d) It is no obstacle to the sum stipulated being a genuine pre-estimate of damage, that consequences of the breach are such as to make precise pre-estimation almost an impossibility. On the contrary, that is just that situation when it is probable that pre-estimated damage was the true bargain between the parties (Clydebank Case, Lord Halsbury  A. C. at p. 11.; Webster v. Bosanquet, Lord Mersey  A. C. at p. 398).
Per Lord Diplock in Scandinavian Trading Tanker Co AB v Flota Petrolera Ecuatoriana (The Scaptrade)  2 All ER 763 at p.767:
The classic form of penalty clause is one which provides that on breach of a primary obligation under the contract, a secondary obligation shall arise on the party in breach to pay to the other party a sum of money which does not represent a genuine pre-estimate of any loss likely to be sustained by him as the result of the breach of primary obligation but is substantially in excess of that sum. The classic form of relief against such a penalty clause has been to refuse to give effect to it, but to award the common law measure of damages for the breach of primary obligation instead.
Lordsvale Finance plc v Bank of Zambia  QB 752 at 762H, per Colman J:
…whether a provision is to be treated as a penalty is a matter of construction to be resolved by asking whether at the time the contract was entered into the predominant contractual function of the provision was to deter a party from breaking the contract or to compensate the innocent party for breach. That the contractual function is deterrent rather than compensatory can be deduced by comparing the amount that would be payable on breach with the loss that might be sustained if breach occurred.
In Parkingeye Ltd v Beavis  EWCA Civ 402 per Moore-Bick LJ at paras 13 and 27:
13. …The cases all concerned clauses stipulating for sums payable on breach of contract and since the contract in each case was of an ordinary commercial nature it was possible to take only two views of the clause: either it was a genuine pre-estimate of damage or a conventional amount agreed upon to dispense with the need to ascertain damages in circumstances where they would be difficult to quantify, in which case it would be enforceable as liquidated damages; or it far exceeded any loss which the injured party could conceivably suffer, in which case it was regarded as being extravagant and unconscionable and therefore unenforceable as a penalty. As a result, it was for a long time routine to examine clauses of this kind by reference to a dichotomy between liquidated damages and penalties. The characteristic of deterrence, as opposed to compensation, which has sometimes been treated as the key to drawing a distinction between the two, seems to me simply to reflect the fact that only a stipulation which is extravagant and unconscionable is likely to be regarded as a deterrent, and therefore as a penalty, and so justify the courts in refusing to enforce it.
27. … the fact that the contract provides for the payment on breach of a sum which significantly exceeds the greatest loss that the law would recognise as having been suffered by the injured party is in most circumstances a strong indication that the bargain is extravagant and unconscionable, but other factors may be present which rob the bargain of that character. Those factors may be of a commercial nature, as they were in Lordsvale and Murray, but I see no reason in principle why other factors should not be capable of leading to the same conclusion. In the present case it is possible to present the charges, as the judge did, as commercially justifiable, but in truth they are justified by a combination of factors, social as well as commercial. In the commercial context a "dominant purpose of deterrence" has been equated to extravagance and unconscionability, but in another context that need not be the case.