refactor exceededMaxStatesPerUrl and added tests