fix readable forms in the case of a top-level ref-less group

fixes http://manage.dimagi.com/default.asp?124053

first commit fixes, second commit adds regression test
I prefer to include a message in assertions like this so you have more context about what went wrong if it ever failed. Example:

```python
assert path_context.endswith('/'), path_context
```