fixed computing of thumbnails, and added unit tests