refactors shell. adds tests (WIP)