Tests and fixes