Use #[cfg(test)] instead of #[test].
Simplify index methods