Add trailing slash when it should make sense

Add also a couple of tests to test this behavior
pep8 cleanup in some tests