fixed cell referencing, added some unit tests