Tokens namespace

Splitting token related functions and functions that handle request
into two different namespaces.

Adding tests for functions relate to tokens life-cycle.