Added ref tests, more implementation work.