tests and code addressing @jdalton 's comments. also wired up type tests