Refactored bootstrap and lots of added tests.