URL encoding bugfix and add more tests.