Write test for [] method