[fixes #50] --port and PORT both work.

- some misc cleanup
- more tests