MDL-42253 course management: fixed course pagination

If the number of courses === the number per page pagination
was being incorrectly rendered.
Fixed this and added a behat test to confirm it.