Hepatitis Lab diagnosis based on serology
HBcAg is capsuled by HBsAg and therefore can't be detected, while within the cells it's still free (before assembly of the virus).
The test checks for presence of antibodies (IgM) against HBcAg. It does not try to detect HBsAg anyways.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC154683/