Refactored Token code
Tests for Token code