Optimize reference
Add new tests