fixed a little indexing bug + added test cases