add spec tests
fix issues found when running spec tests

Fix-ups for bugs and inconsistencies found when
running the spec tests.
WIP: spec for factory::add_step
WIP: fix bugs in factory::add_step