Added checks for empty source and key. Cleaned up tests.