url encode key once creating url
fix unit tests