Refactor off function
Added test for 'on' function
Better split
Refactor