reimplemented interval modulo with some unit tests