move 'after' outside main transaction for SQLite and tidy tests