Fix tests for SQLAlchemy 0.8 and 0.9