Little refactoring of dictionary manupulation functions. Added Toggle tests.