testnet support

Hello,

I've added support for testnet coins. I'm assuming you won't like it as is, as it's pretty awkward, but I figured I should make a proposition first before asking for advice on how to best do it.