Add more tests. Fixed an error with optimized queries with offset.
Add one more test (not full last page from the range with offset).
Add optimized queries for looking for a page after the specified message.