Refactor loading frames for GIFs and add tests.