Key refactor

Refactored APIKey and wrote Unit tests