Fixing bug with end minutes and adding tests