Improve `String.prototype.endsWith` polyfill

This patch replaces the old `String.prototype.endsWith` polyfill with http://mths.be/endswith, while also adding the tests from that project.