Fix %bookmark -l for Python 3

Closes gh-5676

Also add a simple test for %bookmark