The fan is directly powered from the ceiling rose ;-( via 3 core & earth cable Red, Blue, Yellow & Earth. Red from loop in (L), Yellow from lamp switch side(Ls), Blue from Neutral side of lamp (N).
Bathroom pull switch has no wires to fan. Toilet switch has single brown wire ( 2 core flex) from Ls to a connector strip in loft space. Once I'd unwrapped twenty meters of insulation tape from it I saw that it has 4 terminals. Connections are from bathroom 3 core & earth to fan motor. Fan motor wiring is Brown, Yellow/Green and Blue. Connections are Red > Brown, Yellow > Yellow/Green, Blue > Blue, bare earth wire unconnected, Brown wire from Toilet pull switch Ls connected to Red on terminal block. I whole it's a mess up. I've disconnected the brown wire from the toilet switch so that now the lights work independently. Obvious actions are to replace the connector strip with a junction box. What do I need to do to make this arrangement work safely?