Improve compatibility for :buffer command and add tests for existing behaviour

The `:buffer` command now

 1. Behaves correctly when given a buffer reference of `%`, which is to do nothing.
 2. Accepts the buffer command as a count.

I've also added tests for the functionality that was already there but not tested.