restored some code, fixed broken unittest