Here's a patch that has both a fix and an improved unit test. There are basically 3 scenarios, all of which now get tested:
1. User does an interactive command with the "numberToKeep" request param.
2. User has "maxBackupsToKeep" in their configuration but it still doing backups using the interactive command.
3. User is relying on commits to do backups automatically.
I will commit to Trunk and 3.x (3.6.1) shortly.