Added max heartbeat interval to prevent integer overflow 

Forward port to master from https://github.com/owncloud/core/pull/9016

Bonus unit tests have been added for that case :smile: 

Please review @icewind1991 @schiesbn @MorrisJobke