Fix minor issues + Add tests

All are in the title...

ping @tmartin