fix references stuff and test