Added Spock for testing
Fixed index flattening problem