Fix $k$ an algebraically closed field, $n$ a natural number, and $\lambda=(\lambda_1,\ldots,\lambda_m)$ a partition of $n$. Let $A$ be any $n\times n$ nilpotent matrix with entries in $k$ whose Jordan form corresponds to the partition $\lambda$. Consider the variety $X_{A}$ of pairs of commuting nilpotent matrices which also commute with $A$:
$$X_{A}=\{(B,C)\in C_{\mathfrak{gl}_n}(A)^{\times2}\mid B^n=C^n=0,\;BC=CB\}$$
I'm interested in computing the dimension of $X_{A}$. My initial computations with Magma suggest the following conjecture:
If $s_i=|\{j|\lambda_j\ge i\}|$ then$$\dim X_{A}=n+\sum s_i^2-m-1$$
(The program I've written in Magma can't handle partitions of $\ge4$ parts, so although all computations thus far agree with the above formula, the evidence is far from conclusive)
How might I compute the dimension of $X_{A}$? Any general advice or techniques used in computing dimension?