Cleaning up upstream tests

I don't think I made any meaningful changes to code, but please review :)
@hash3g I fixed (badly) in following direct commit