Added api key validation method with tests