refactor and more tests

refactoring the toggle functionality
and adding in much more test coverage..

still could be better