Refactoring source code layout and fixing Karma setup