Refactoring interval functions and the performance test. Increasing test coverage. Added a new random generation with tests.