Fix #620
Remove empty lines
Add test to make sure indices are correct
Merge branch 'pr/622'