Add unit tests and fix component ordering