Refactor txtopairs into smaller functions

Also adds a test for one of the new functions
I think a check for an actually spendable output (so, P2PKH) should be performed during the input selection, not when adding inputs from already selected eligible previous outputs.