Add tests
fix undefined index