refs: Add tests and fix found issues