Fixed broken test and minor code style refactoring