Increasing test coverage and fixing bugs found while writing tests

Could also be a list comprehension here.