Added PerForeignKeyTemplatesTestTemplateWritingHandlerTest. Refactored test also for per-table writing handler. refs #474