Fix switching analysis on and off + unit tests