Major refactoring, tests added and bower support added