fixed bug in select_first and added a couple more tests