More tests and a fix for a bug introduced with latest refactorings