Testing with a nuisance parameter present only under the alternative: a score-based approach with application to segmented modelling