Fix it to work with Pergamum 2, add tests.