There is no consensus among linguists on how the parts of speech issue is best handled for the trickier cases.
Bas Aarts, in The Handbook of English Linguistics 2006 (ed Aarts & McMahon): English Word Classes and Phrases (Aarts & Haegeman): 2.3 Word class boundaries and gradience gives the analyses of three opposing schools [the extract below is modified].
We could approach ... [the examples given are for ing-form usages] in at least three ways:
Firstly, we could say that verbs and nouns are on a cline or gradient, such that these word classes shade into each other gradually.
Another possibility is to say that [the word in question in its usage in an actual example] is a hybrid element and belongs to the classes [here verb and noun] at the same time. This strategy is adopted in cognitive approaches to grammar. It is also proposed [by] Hudson (2003).
A third possible strategy would be to retain the [traditional/fairytale?] sharp boundaries between the [here] verb and noun categories, and say that though V-ing in sentence A has verbal as well as nominal properties, the verbal ones outweigh the nominal ones.... [And who gets to decide this!?]
Testing for nouns and verbs say is not like doing an A-level chemistry inorganic analysis on a mixture of salts. There, it's indisputable that there is a single correct answer; the single problem the candidates have is to apply the tests correctly. With parts of speech, the periodic table hasn't been agreed upon.