Improved tests & fixed nesting