Rational points on singular curves, with applications to the Brauer-Manin obstruction on surfaces