Completed KDF function and added unit test